package com.css.fxfzaqbz.modules.supergraph.service.impl;

import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.css.fxfzaqbz.base.response.RestResponse;
import com.css.fxfzaqbz.base.upload.entity.AttachmentInfoEntity;
import com.css.fxfzaqbz.base.upload.service.AttachmentInfoService;
import com.css.fxfzaqbz.modules.assess1.entity.AlgEntity;
import com.css.fxfzaqbz.modules.assess1.service.impl.DestoryAlgServiceImpl;
import com.css.fxfzaqbz.modules.assessplot.entity.EvaluationResults;
import com.css.fxfzaqbz.modules.assessplot.service.EvaluationResultsService;
import com.css.fxfzaqbz.modules.base.entity.District;
import com.css.fxfzaqbz.modules.base.entity.HouseData;
import com.css.fxfzaqbz.modules.base.entity.NetworkanalystVersion;
import com.css.fxfzaqbz.modules.base.service.HypergraphService;
import com.css.fxfzaqbz.modules.callJcData.entity.Gasholder;
import com.css.fxfzaqbz.modules.callJcData.service.GasholderService;
import com.css.fxfzaqbz.modules.data.entity.Site;
import com.css.fxfzaqbz.modules.data.repository.DistrictBoundaryRepository;
import com.css.fxfzaqbz.modules.estimate.service.FaultService;
import com.css.fxfzaqbz.modules.maps.vo.MapViewVO;
import com.css.fxfzaqbz.modules.maps.entity.ProfessionMap;
import com.css.fxfzaqbz.modules.maps.service.MapManagerService;
import com.css.fxfzaqbz.modules.supergraph.entity.*;
import com.css.fxfzaqbz.modules.supergraph.exception.CustomException;
import com.css.fxfzaqbz.modules.supergraph.repository.EmergcyShelterRepository;
import com.css.fxfzaqbz.modules.supergraph.repository.OrgDivisionRepository;
import com.css.fxfzaqbz.modules.supergraph.repository.SupergraphRepository;
import com.css.fxfzaqbz.modules.supergraph.service.SupergraphService;
import com.css.fxfzaqbz.modules.supergraph.vo.*;
import com.css.fxfzaqbz.util.DownloadsFile;
import com.css.fxfzaqbz.util.PlatformObjectUtils;
import com.css.fxfzaqbz.util.RestTemplateUtil;
import com.css.fxfzaqbz.util.UUIDGenerator;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Polygon;
import org.locationtech.jts.util.GeometricShapeFactory;
import org.slw.common.helper.PropsHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.http.*;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.*;

/**
 * @author y1fan
 * @create 2023-02-07 17:22
 */
@Slf4j
@Service
public class SupergraphServiceImpl implements SupergraphService {
    @Resource
    RestTemplateUtil restTemplateUtil;

    @Value("${image.localDir}")
    private String localDir;


    @Resource
    private DownloadsFile downloadsFile;

    @Resource
    private SupergraphRepository supergraphRepository;

    @Resource
    private AttachmentInfoService attachmentInfoService;

    @Resource
    private MapManagerService mapManagerService;
    @Resource
    private DistrictBoundaryRepository districtBoundaryRepository;

    @Resource
    private OrgDivisionRepository orgDivisionRepository;

    @Resource
    private HypergraphService hypergraphService;

    @Resource
    GasholderService gasholderService;
    @Resource
    EmergcyShelterRepository emergcyShelterRepository;
    @Resource
    EvaluationResultsService evaluationResultsService;
    @Autowired
    private FaultService faultService;
//    @Resource
//    RestTemplate restTemplate;
    RestTemplate restTemplate = getRestTemplate();

    /**
     * 调度器使用的RestTemplate，超时600s
     * @return
     */
    public RestTemplate getRestTemplate(){
        RestTemplate restTemplate = new RestTemplateBuilder()
                .setConnectTimeout(Duration.ofSeconds(600))
                .setReadTimeout(Duration.ofSeconds(600))
                .build();
        //解决中文乱码
        List<HttpMessageConverter<?>> msgConv = restTemplate.getMessageConverters();
        if(msgConv != null && !msgConv.isEmpty()) {
            for(int i = 0; i < msgConv.size(); i++ ){
                if(msgConv.get(i).getClass().equals(StringHttpMessageConverter.class)) {
                    msgConv.set(i, new StringHttpMessageConverter(StandardCharsets.UTF_8));
                }
            }
        }
        return restTemplate;
    }

    public HashMap<String, Double> getPeopleNearby(BigDecimal longitude, BigDecimal latitude, Double distince) {
        double r = 6371.393;    // 地球半径千米
        double lng = longitude.doubleValue();
        double lat = latitude.doubleValue();
        double dlng = 2 * Math.asin(Math.sin(distince / (2 * r)) / Math.cos(lat * Math.PI / 180));
        dlng = dlng * 180 / Math.PI;// 角度转为弧度
        double dlat = distince / r;
        dlat = dlat * 180 / Math.PI;
        double minlat = lat - dlat;
        double maxlat = lat + dlat;
        double minlng = lng - dlng;
        double maxlng = lng + dlng;

        HashMap<String, Double> map = new HashMap<>();
        map.put("minlng", minlng);
        map.put("maxlng", maxlng);
        map.put("minlat", minlat);
        map.put("maxlat", maxlat);
        return map;
    }

    //获取经纬网参数
    public MapGridOptions getMapGridOptions(double leftBottom_X,double leftBottom_Y,double rightTop_X,double rightTop_Y) {
        double minLon = leftBottom_X;
        double minLat = leftBottom_Y;
        double maxLon = rightTop_X;
        double maxLat = rightTop_Y;
        //获取经度差值
        double diffLon = maxLon - minLon;
        double tempLon = diffLon / 4;
        if(tempLon>1){
            tempLon = Math.round(tempLon);
        }else if(tempLon>0.5){
            tempLon = 0.5;//30分
        }else if(tempLon>0.25){
            tempLon = 0.25;//15分
        }else if(tempLon>0.125){
            tempLon = 0.125;//7分30秒
        }else if(tempLon>0.0625){
            tempLon = 0.0625;//3分45秒
        }else if(tempLon>0.05){
            tempLon = 0.05;//3分
        }else if(tempLon>0.025){
            tempLon = 0.025;//1分30秒
        }else if(tempLon>0.0125){
            tempLon = 0.0125;//45秒
        }else{
            tempLon = 0.0025;//9秒
        }
        //获取纬度差值
        double diffLat = maxLat - minLat;
        double tempLat = diffLat / 3;
        if(tempLat>1){
            tempLat = Math.round(tempLat);
        }else if(tempLat>0.5){
            tempLat = 0.5;//30分
        }else if(tempLat>0.25){
            tempLat = 0.25;//15分
        }else if(tempLat>0.125){
            tempLat = 0.125;//7分30秒
        }else if(tempLat>0.0625){
            tempLat = 0.0625;//3分45秒
        }else if(tempLat>0.05){
            tempLat = 0.05;//3分
        }else if(tempLat>0.025){
            tempLat = 0.025;//1分30秒
        }else if(tempLat>0.0125){
            tempLat = 0.0125;//45秒
        }else{
            tempLat = 0.0025;//9秒
        }
        MapGridOptions mapGridOptions = new MapGridOptions();//经纬度网格边框
        mapGridOptions.setOriginX(-180);
        mapGridOptions.setOriginY(-90);
        mapGridOptions.setCellWidth(tempLon);
        mapGridOptions.setCellHeight(tempLat);
        mapGridOptions.setMarkType("DMS");

        return mapGridOptions;
    }

    //根据level获取经纬网参数
    public MapGridOptions getMapGridOptionsByLevel(double level) {
        int[] levelArr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18};
        double[] cellDiffArr = {160, 80, 40, 20, 10, 5, 2.5, 1.25, 0.5, 0.25, 0.125, 0.0625, 0.05, 0.025, 0.0125, 0.005, 0.0025, 0.0011};
        double cellDiff = 1;
        for(int i=0;i<levelArr.length;i++){
            if(levelArr[i]==level){
                cellDiff = cellDiffArr[i];
                break;
            }
        }
        MapGridOptions mapGridOptions = new MapGridOptions();//经纬度网格边框
        mapGridOptions.setOriginX(-180);
        mapGridOptions.setOriginY(-90);
        mapGridOptions.setCellWidth(cellDiff);
        mapGridOptions.setCellHeight(cellDiff);
        mapGridOptions.setMarkType("DMS");

        return mapGridOptions;
    }

    //根据经纬度范围获取level值
    public int getLevel(double leftBottom_X,double leftBottom_Y,double rightTop_X,double rightTop_Y,TemplateEntity templateEntity) {
        int level = 4;//默认级别4
        double minLon = leftBottom_X;
        double minLat = leftBottom_Y;
        double maxLon = rightTop_X;
        double maxLat = rightTop_Y;
        //获取最大差值
        double diffLon = maxLon - minLon;
        double diffLat = maxLat - minLat;
        double diffMax = diffLon;
        if(diffLon < diffLat){
            diffMax = diffLat;
        }
        /*//1-18缩放级别zoom
        int[] levelArr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18};
        Double[] diffArr = {360.0,180.0,90.0,45.0,22.0,11.0,5.0,2.5,1.25, 0.6,0.3,0.15,0.07,0.03,0.015,0.007,0.0003,0.00015};
        for (int i = 0; i < diffArr.length; i++) {
            if (diffMax - diffArr[i] >= 0) {
                level = levelArr[i];
                break;
            }
        }*/

        //横版不带简介hf1012
        int width = 1510;
        int height = 1020;
        //根据超图模板信息
        if(templateEntity!=null){
            width = templateEntity.getWebMapFrameSizeX();//图件宽度
            height = templateEntity.getWebMapFrameSizeY();//图件高度
        }
        //根据区域范围计算zoom级别，width、height是以像素为单位的地图布局大小
        level = getBoundsZoomLevel(leftBottom_X,leftBottom_Y,rightTop_X,rightTop_Y,width, height);
        //至少为4级，防止地图经纬度格网不显示
        if(level<4){
            level = 4;
        }

        return level;
    }

    final static int GLOBE_WIDTH = 256;
    final static int ZOOM_MAX = 18;
    //根据区域范围计算zoom级别，width、height是以像素为单位的地图布局大小
    public static int getBoundsZoomLevel(double leftBottom_X,double leftBottom_Y,double rightTop_X,double rightTop_Y,
                                         int width, int height) {
        double latFraction = (latRad(rightTop_Y) - latRad(leftBottom_Y)) / Math.PI;
        double lngDiff = rightTop_X - leftBottom_X;
        double lngFraction = ((lngDiff < 0) ? (lngDiff + 360) : lngDiff) / 360;
        double latZoom = zoom(height, GLOBE_WIDTH, latFraction);
        double lngZoom = zoom(width, GLOBE_WIDTH, lngFraction);
        double zoom = Math.min(Math.min(latZoom, lngZoom),ZOOM_MAX);
        return (int)(zoom);
    }
    private static double latRad(double lat) {
        double sin = Math.sin(lat * Math.PI / 180);
        double radX2 = Math.log((1 + sin) / (1 - sin)) / 2;
        return Math.max(Math.min(radX2, Math.PI), -Math.PI) / 2;
    }
    private static double zoom(double mapPx, double worldPx, double fraction) {
        final double LN2 = .693147180559945309417;
        return (Math.log(mapPx / worldPx / fraction) / LN2);
    }

    @Resource
    DestoryAlgServiceImpl destoryAlgService;

    @Override
    public RestResponse Supergraph(SupergraphVO supergraphVO) throws InterruptedException {
        //获取超图服务token
        String token = hypergraphService.getToken();
        if (PlatformObjectUtils.isEmpty(token)) {
            return RestResponse.fail("缺少超图服务token");
        }
        RestResponse restResponse = null;
        //出图范围 km为单位
        Double ctfw = supergraphVO.getCtfw();
        //制图单位
        String ztdw = supergraphVO.getZtdw();
        //重点目标
        String zdmb = supergraphVO.getZdmb();

        //根据重点目标名称查询Site对象
        Site site = supergraphRepository.getSiteByName(zdmb);
        Double centerX = site.getSsLongitude();
        Double centerY = site.getSsLatitude();
        HashMap<String, Double> hashMap = getPeopleNearby(BigDecimal.valueOf(centerX), BigDecimal.valueOf(centerY), ctfw);
        Double leftX = hashMap.get("minlng");
        Double leftY = hashMap.get("minlat");
        Double rightX = hashMap.get("maxlng");
        Double rightY = hashMap.get("maxlat");
//        //测试北京市范围
//        centerX = 116.41257667603315;
//        centerY = 40.185597596456724;
//        leftX = 115.41681500100003;
//        leftY = 39.44212869000006;
//        rightX = 117.50822604300004;
//        rightY = 41.05921014200004;
        int level = getLevel(leftX, leftY, rightX, rightY,null);
        Properties configGroup = PropsHelper.loadProps("slw-config.properties");
        List<TjVO> tjvos = supergraphVO.getTjvos();
        for (TjVO tjvo : tjvos) {
            if ("避难场所分布图".equals(tjvo.getTjlx())) {
                //按版本删除场所辐射范围
                emergcyShelterRepository.delete(tjvo.getDataVersion());
                /*String urlu = configGroup.getProperty("restTemplateUrl") + "/datacenter/jcEmergcyShelter/findByGeom";
                String geom = leftX + " " + leftY + "," + rightX + " " + leftY + "," + rightX + " " + rightY + "," + leftX + " " + rightY + "," + leftX + " " + leftY;
                Map<String, Object> map1 = new HashMap<>();
                map1.put("geom", geom);
                if (PlatformObjectUtils.isNotEmpty(tjvo.getDataVersion())) {
                    map1.put("dataVersion", tjvo.getDataVersion());
                }
                ResponseEntity<String> stringResponseEntity1 = restTemplateUtil.sendHttpRequestPj(urlu, map1);
                String body1 = stringResponseEntity1.getBody();
                List<JcEmergcyShelterVo> jcEmergcyShelterVos = JSON.parseArray(body1, JcEmergcyShelterVo.class);*/

                //获取出图范围内的应急避难场所
                List<JcEmergcyShelterVo> jcEmergcyShelterVos = new ArrayList<>();
                String geom = "POLYGON((" + leftX + " " + leftY + "," + rightX + " " + leftY + "," + rightX + " " + rightY + "," + leftX + " " + rightY + "," + leftX + " " + leftY + "))";
                String urlu = configGroup.getProperty("restTemplateUrl") + "/datacenter/jcEmergcyShelter/findByGeom" +
                        "?dataVersion="+tjvo.getDataVersion()+"&geom="+geom+"&code="+tjvo.getNum();
                JSONObject valueMap = new JSONObject();
                JSONArray jsonArray = (JSONArray) hypergraphService.getJCSJ(urlu, 3, valueMap).getData();
                if(jsonArray!=null && jsonArray.size()>0){
                    for(int i=0;i<jsonArray.size();i++){
                        JSONObject obj = jsonArray.getJSONObject(i);
                        JcEmergcyShelterVo jcEmergcyShelterVo = new JcEmergcyShelterVo();
                        jcEmergcyShelterVo.setBncsmc(obj.getString("bncsmc"));
                        jcEmergcyShelterVo.setJesLongitude(obj.getDouble("jesLongitude"));
                        jcEmergcyShelterVo.setJesLatitude(obj.getDouble("jesLatitude"));
                        jcEmergcyShelterVos.add(jcEmergcyShelterVo);
                    }
                }

                if (jcEmergcyShelterVos.size() > 0) {

                    for (JcEmergcyShelterVo jcEmergcyShelterVo : jcEmergcyShelterVos) {
                        Double bj = 0.0;
                        if ("1".equals(jcEmergcyShelterVo.getShelterClass())) {
                            bj = 10000.0;
                        }
                        if ("2".equals(jcEmergcyShelterVo.getShelterClass())) {
                            bj = 2500.0;
                        }
                        if ("3".equals(jcEmergcyShelterVo.getShelterClass())) {
                            bj = 1000.0;
                        }
                        if ("4".equals(jcEmergcyShelterVo.getShelterClass())) {
                            bj = 500.0;
                        }
                        Polygon circle = createCircle(jcEmergcyShelterVo.getJesLongitude(), jcEmergcyShelterVo.getJesLatitude(), bj);
                        EmergcyShelter emergcyShelter = new EmergcyShelter();
                        emergcyShelter.setId(UUIDGenerator.getUUID());
                        emergcyShelter.setName(jcEmergcyShelterVo.getBncsmc());
                        emergcyShelter.setLongitude(jcEmergcyShelterVo.getJesLongitude());
                        emergcyShelter.setLatitude(jcEmergcyShelterVo.getJesLatitude());
                        emergcyShelter.setGeom(circle.toString());
                        if (PlatformObjectUtils.isNotEmpty(jcEmergcyShelterVo.getShelterClass())) {
                            emergcyShelter.setShelterClass(jcEmergcyShelterVo.getShelterClass());
                        }
                        emergcyShelter.setDelFlag("0");
                        emergcyShelter.setDataVersion(tjvo.getDataVersion());
                        emergcyShelterRepository.save(emergcyShelter);
                    }
                    //刷新指定超图工作空间数据源数据集
                    hypergraphService.getWorkspaceReload("sys_emergcy_shelter");
                }

            }
        }

        //获取Web打印出图模板列表
        List<TemplateEntity> templateEntityList = hypergraphService.getWebprintingLayoutsList();

        List<Map<String, Object>> list = new ArrayList<>();
        //前端传过来的类型对象集合
        List<TjVO> tjVOS = supergraphVO.getTjvos();
        for (TjVO tjVO : tjVOS) {
            String id = tjVO.getXzmb();
            MapViewVO view = mapManagerService.view(id);
            String titleNum = view.getType();
            String count = clTitle(titleNum);
            //根据图件数据版本信息获取临时图层URL的Map
            Map<String,String> tempLayerUrlMap = getTempLayerUrlMapByTjVO(tjVO);
            List<Layer> layers = getLayer(tjVO.getTjlx(),tempLayerUrlMap);
            List<Layerr> layerrs = getLayerrs(tjVO.getTjlx(),tempLayerUrlMap,tjVO.getDataVersion());

            //根据参数设置请求体
            String jsonString = getRequestVOJsonStringByTjmb(tjVO.getXzmb(),templateEntityList,tjVO.getTjbt(),ztdw,layerrs,layers,centerX,centerY,leftX,leftY,rightX,rightY,level,false);
            Map map = JSONObject.parseObject(jsonString, Map.class);
            String url = configGroup.getProperty("supergraphRestTemplateUrl") + "/webprinting/rest/webprinting/v1/jobs.json?token=" + token;
            ResponseEntity<String> stringResponseEntity = restTemplateUtil.sendPostHttpRequest2(url, map);
            String body = stringResponseEntity.getBody();
            List<ResponseVO> responseVO = JSON.parseArray(body, ResponseVO.class);
            String path = "";
            String imageId = "";

            if (responseVO != null || responseVO.size() > 0) {
                path = responseVO.get(0).getPath() + "/" + "result";
                //    String dateDir = new SimpleDateFormat("/yyyy/MM/dd").format(new Date());
                String savePath = localDir;
                path = path.replace("@", "%40");
                System.out.println("路径  " + path);
                String path2 = responseVO.get(0).getPath() + ".rjson";
                Map<String, Object> map2 = new HashMap<>();
                boolean flag = true;
                while (flag) {
                    ResponseEntity<String> responseEntity = restTemplateUtil.sendHttpRequest3(path2, map2);
                    String body1 = responseEntity.getBody();
                    String[] split1 = body1.split("status");
                    if (split1[1].contains("ERROR")) {
                        log.error("超图服务打印失败");
                        return RestResponse.fail("超图服务打印失败");
                    }
                    if (split1[1].contains("FINISHED")){
                        flag = false;
                        continue;
                    }
                    Thread.sleep(500);
                }
                restResponse = downloadsFile.downloadByUrl(path, savePath);
                imageId = restResponse.getData().toString();
                Map<String, Object> responseMap = new HashMap<>();
                AttachmentInfoEntity attach = attachmentInfoService.getAttach(imageId);
                responseMap.put("attach", attach);
                responseMap.put("count", count);
                responseMap.put("title", "");
                responseMap.put("zdmb", zdmb);
                list.add(responseMap);
            }
            File file = new File(localDir);
            File[] files = file.listFiles();
            for (File file1 : files) {
                if (file1.isFile()) {
                    file1.delete();
                }
            }

        }
        restResponse = RestResponse.succeed(list);
        return restResponse;
    }

    //根据模板名、模板信息列表获取模板信息
    public TemplateEntity getTemplateEntityByTemplateName(String templateName,List<TemplateEntity> templateEntityList){
        TemplateEntity templateEntity = null;
        if (PlatformObjectUtils.isNotEmpty(templateName) && templateEntityList.size()>0){
            for(TemplateEntity entity : templateEntityList){
                if(templateName.equals(entity.getTemplateName())){
                    templateEntity = entity;
                    break;
                }
            }
        }

        return templateEntity;
    }

    //根据图件数据版本信息获取临时图层URL的Map
    public Map<String,String> getTempLayerUrlMapByTjVO(TjVO tjVO){
        Map<String,String> tempLayerUrlMap = new HashMap<>();
        String tjlx = tjVO.getTjlx();//图件类型
        String dataVersion = tjVO.getDataVersion();//数据版本
        String num = tjVO.getNum();//数据类型num
        if (PlatformObjectUtils.isNotEmpty(dataVersion) && PlatformObjectUtils.isNotEmpty(num)) {
            if ("物资储备库分布图".equals(tjlx)) {
                String tempLayerUrl = getTempLayerUrlByDataType("jc_material_reserve",dataVersion);
                tempLayerUrlMap.put("jc_material_reserve",tempLayerUrl);
            }else if ("医院分布图".equals(tjlx)) {
                String tempLayerUrl = getTempLayerUrlByDataType("jc_rfcp_hospital",dataVersion);
                tempLayerUrlMap.put("jc_rfcp_hospital",tempLayerUrl);
            }else if ("学校分布图".equals(tjlx)) {
                String tempLayerUrl = getTempLayerUrlByDataType("jc_rfcp_school",dataVersion);
                tempLayerUrlMap.put("jc_rfcp_school",tempLayerUrl);
                String tempLayerUrl1 = getTempLayerUrlByDataType("中小学分布图中小学",dataVersion);
                tempLayerUrlMap.put("中小学分布图中小学",tempLayerUrl1);
            }else if ("避难场所分布图".equals(tjlx)) {
                String tempLayerUrl = getTempLayerUrlByDataType("jc_emergcy_shelter",dataVersion);
                tempLayerUrlMap.put("jc_emergcy_shelter",tempLayerUrl);
                String tempLayerUrl1 = getTempLayerUrlByDataType("sys_emergcy_shelter",dataVersion);
                tempLayerUrlMap.put("sys_emergcy_shelter",tempLayerUrl1);
            }else if("断层分布图".equals(tjlx)){
                String tempLayerUrl = getTempLayerUrlByDataType("断层分布图最新活动时代",dataVersion);
                tempLayerUrlMap.put("断层分布图最新活动时代",tempLayerUrl);
            }else if ("地震构造图".equals(tjlx)){
                String dcDataVersion = dataVersion.split(",")[0];
                String dcyxDataVersion = dataVersion.split(",")[1];
                String tempLayerUrl = getTempLayerUrlByDataType("地震构造图地层年代",dcyxDataVersion);
                tempLayerUrlMap.put("地震构造图地层年代",tempLayerUrl);
                String tempLayerUrl1 = getTempLayerUrlByDataType("地震构造图最新活动时代",dcDataVersion);
                tempLayerUrlMap.put("地震构造图最新活动时代",tempLayerUrl1);
                String tempLayerUrl2 = getTempLayerUrlByDataType("地震构造图断层性质",dcDataVersion);
                tempLayerUrlMap.put("地震构造图断层性质",tempLayerUrl2);
//                String tempLayerUrl2 = getTempLayerUrlByDataType("jc_fault2",dcDataVersion);
//                tempLayerUrlMap.put("jc_fault2",tempLayerUrl2);
            }else if ("历史地震分布图".equals(tjlx)){
                String tempLayerUrl = getTempLayerUrlByDataType("历史地震分布图活动断裂",dataVersion);
                tempLayerUrlMap.put("历史地震分布图活动断裂",tempLayerUrl);
            }else if ("人员伤亡分布图".equals(tjlx)){
                String tempLayerUrl = getTempLayerUrlByDataType("sys_destory_alg",dataVersion);
                tempLayerUrlMap.put("sys_destory_alg",tempLayerUrl);
            }else if ("地震灾害风险等级分布图".equals(tjlx)){
                String tempLayerUrl = getTempLayerUrlByDataType("sys_destory_alg_level",dataVersion);
                tempLayerUrlMap.put("sys_destory_alg_level",tempLayerUrl);
            }else if("易燃易爆危险源分布图".equals(tjlx)){
                String[] dataVersionArr = dataVersion.split(",");
                String cqgDataVersion = dataVersionArr[0];
                String jyzDataVersion = dataVersionArr[1];
                String whqyDataVersion = dataVersionArr[2];
                String tempLayerUrl1 = getTempLayerUrlByDataType("sys_gasholder",cqgDataVersion);
                tempLayerUrlMap.put("sys_gasholder",tempLayerUrl1);
                String tempLayerUrl2 = getTempLayerUrlByDataType("jc_lfcp_gas_station",jyzDataVersion);
                tempLayerUrlMap.put("jc_lfcp_gas_station",tempLayerUrl2);
                String tempLayerUrl3 = getTempLayerUrlByDataType("jc_dangerous_enterprise",whqyDataVersion);
                tempLayerUrlMap.put("jc_dangerous_enterprise",tempLayerUrl3);
            }else if("危险源避让分布图".equals(tjlx)){
                //危险源避让范围
                String tempLayerUrl = getTempLayerUrlByDataType("sys_gasholder_br",dataVersion);
                tempLayerUrlMap.put("sys_gasholder_br",tempLayerUrl);
                //危险源
                String[] dataVersionArr = dataVersion.split(",");
                String cqgDataVersion = dataVersionArr[0];
                String jyzDataVersion = dataVersionArr[1];
                String whqyDataVersion = dataVersionArr[2];
                String tempLayerUrl1 = getTempLayerUrlByDataType("sys_gasholder",cqgDataVersion);
                tempLayerUrlMap.put("sys_gasholder",tempLayerUrl1);
                String tempLayerUrl2 = getTempLayerUrlByDataType("jc_lfcp_gas_station",jyzDataVersion);
                tempLayerUrlMap.put("jc_lfcp_gas_station",tempLayerUrl2);
                String tempLayerUrl3 = getTempLayerUrlByDataType("jc_dangerous_enterprise",whqyDataVersion);
                tempLayerUrlMap.put("jc_dangerous_enterprise",tempLayerUrl3);
            }else if ("地质灾害隐患点分布图".equals(tjlx)){
                String tempLayerUrl = getTempLayerUrlByDataType("地质灾害隐患点分布图",dataVersion);
                tempLayerUrlMap.put("地质灾害隐患点分布图",tempLayerUrl);
            }else if ("人口分布图".equals(tjlx)){
                String tempLayerUrl = getTempLayerUrlByDataType("人口分布图",dataVersion);
                tempLayerUrlMap.put("人口分布图",tempLayerUrl);
            }

        }
        return tempLayerUrlMap;
    }

    //根据表名、数据版本获取临时图层URL
    public String getTempLayerUrlByDataType(String tableName,String dataVersion){
        String tempLayerUrl = "";
        String layerUrl = "";
        String sqlText = "";
        Properties configGroup = PropsHelper.loadProps("slw-config.properties");
        String url = configGroup.getProperty("supergraphRestTemplateUrl");
        //一键出图
        if(tableName.equals("jc_material_reserve")){//物资储备库
            layerUrl = url + "/map-datacenter/rest/maps/jc_material_reserve@datacenter";
            sqlText = "data_version='"+dataVersion+"' and del_flag='0'";
        }else if(tableName.equals("jc_rfcp_hospital")){//医院
            layerUrl = url + "/map-datacenter/rest/maps/医院分布图医院";
            sqlText = "data_version='"+dataVersion+"' and del_flag='0'";
        }else if(tableName.equals("jc_rfcp_school")){//学校
            layerUrl = url + "/map-datacenter/rest/maps/jc_rfcp_school@datacenter";
            sqlText = "data_version='"+dataVersion+"' and del_flag='0'";
        }else if(tableName.equals("中小学分布图中小学")){//学校
            layerUrl = url + "/map-datacenter/rest/maps/中小学分布图中小学";
            sqlText = "data_version='"+dataVersion+"' and del_flag='0'";
        }else if(tableName.equals("jc_emergcy_shelter")){//城市避难场所（点）
            layerUrl = url + "/map-datacenter/rest/maps/应急避难场所分布图避难场所";
            sqlText = "data_version='"+dataVersion+"' and del_flag='0'";
        }else if(tableName.equals("sys_emergcy_shelter")){//场所辐射范围
            layerUrl = url + "/map-fxfzaqbz/rest/maps/sys_emergcy_shelter@fxfzaqbz";
            sqlText = "data_version='"+dataVersion+"' and del_flag='0'";
        }else if (tableName.equals("断层分布图最新活动时代")){
            layerUrl = url + "/map-datacenter/rest/maps/断层分布图最新活动时代";
            sqlText = "data_version='"+dataVersion+"'";
        }else if (tableName.equals("地震构造图地层年代")){
            layerUrl = url + "/map-datacenter/rest/maps/地震构造图地层年代";
            sqlText = "data_version='"+dataVersion+"' and del_flag='0'";
        }else if (tableName.equals("地震构造图最新活动时代")){
            layerUrl = url + "/map-datacenter/rest/maps/地震构造图最新活动时代";
            sqlText = "data_version='"+dataVersion+"' and del_flag='0'";
        }else if (tableName.equals("地震构造图断层性质")){
            layerUrl = url + "/map-datacenter/rest/maps/地震构造图断层性质";
            sqlText = "data_version='"+dataVersion+"' and del_flag='0'";
        }else if (tableName.equals("jc_fault2")){
            layerUrl = url + "/map-datacenter/rest/maps/地震构造图断裂带";
            sqlText = "data_version='"+dataVersion+"' and del_flag='0'";
        }else if (tableName.equals("历史地震分布图活动断裂")){
            layerUrl = url + "/map-datacenter/rest/maps/历史地震分布图活动断裂";
            sqlText = "data_version='"+dataVersion+"'";
        }else if (tableName.equals("sys_destory_alg")){
            layerUrl = url + "/map-fxfzaqbz/rest/maps/sys_destory_alg@fxfzaqbz";
            sqlText = "result_analysis='"+dataVersion+"'";
        }else if (tableName.equals("sys_destory_alg_level")){
            layerUrl = url + "/map-fxfzaqbz/rest/maps/sys_destory_alg_level@fxfzaqbz";
            sqlText = "result_analysis='"+dataVersion+"'";
        }else if (tableName.equals("sys_gasholder_br")){//危险源避让范围
            layerUrl = url + "/map-fxfzaqbz/rest/maps/sys_gasholder_br@fxfzaqbz";
            sqlText = "data_version='"+dataVersion+"' and del_flag='0'";
        }else if (tableName.equals("sys_gasholder")){//储气罐
            layerUrl = url + "/map-fxfzaqbz/rest/maps/sys_gasholder@fxfzaqbz";
            sqlText = "data_version='"+dataVersion+"' and del_flag='0'";
        }else if (tableName.equals("jc_lfcp_gas_station")){//加油站
            layerUrl = url + "/map-datacenter/rest/maps/jc_lfcp_gas_station@datacenter";
            sqlText = "data_version='"+dataVersion+"' and del_flag='0'";
        }else if (tableName.equals("jc_dangerous_enterprise")){//危化企业
            layerUrl = url + "/map-datacenter/rest/maps/jc_dangerous_enterprise@datacenter";
            sqlText = "data_version='"+dataVersion+"' and del_flag='0'";
        }else if (tableName.equals("地质灾害隐患点分布图")){
            layerUrl = url + "/map-datacenter/rest/maps/地质灾害隐患点分布图";//jc_dangerous_spot
            sqlText = "data_version='"+dataVersion+"' and del_flag='0'";
        }else if (tableName.equals("人口分布图")){
            layerUrl = url + "/map-datacenter/rest/maps/人口分布图";//jc_population
            sqlText = "data_version='"+dataVersion+"' and del_flag='0'";
        }
        if (PlatformObjectUtils.isNotEmpty(layerUrl) && PlatformObjectUtils.isNotEmpty(sqlText)) {
            //获取临时图层
            tempLayerUrl = getSqlTempLayer(layerUrl, sqlText,true);
            System.out.println("临时图层----"+tempLayerUrl);
        }
        return tempLayerUrl;
    }

    private List<Layerr> getLayerrs(String tjlx,Map<String,String> tempLayerUrlMap,String dataVersion) {
        Properties configGroup = PropsHelper.loadProps("slw-config.properties");
        String url = configGroup.getProperty("supergraphRestTemplateUrl");
        List<Layerr> layerrs = null;
        if ("物资储备库分布图".equals(tjlx)) {
            //获取临时图层--物资储备库
            String url1 = tempLayerUrlMap.get("jc_material_reserve");
            //获取图层图例（除文字标签）
            Layerr layerr1 = getLayerrByLayerNameUrl("jc_material_reserve@datacenter",url1);
//            Layerr layerr15 = getLayerrByLayerNameUrl("中国行政区划图",url + "/map-datacenter/rest/maps/中国行政区划图");
//            layerrs = Arrays.asList(layerr15,layerr1);
            layerrs = Arrays.asList(layerr1);
        }else if ("医院分布图".equals(tjlx)) {
            //获取临时图层--医院
            String url1 = tempLayerUrlMap.get("jc_rfcp_hospital");
            //获取图层图例（除文字标签）
            Layerr layerr1 = getLayerrByLayerNameUrl("医院分布图医院",url1);
            Layerr layerr2 = getLayerrByLayerNameUrl("中小学分布图铁路",url + "/map-datacenter/rest/maps/中小学分布图铁路");
            Layerr layerr3 = getLayerrByLayerNameUrl("中小学分布图道路",url + "/map-datacenter/rest/maps/中小学分布图道路");
            Layerr layerr4 = getLayerrByLayerNameUrl("中小学分布图水系",url + "/map-datacenter/rest/maps/中小学分布图水系");
            Layerr layerr5 = getLayerrByLayerNameUrl("中小学分布图建筑物",url + "/map-datacenter/rest/maps/中小学分布图建筑物");
            layerrs = Arrays.asList(layerr4, layerr3, layerr2, layerr5, layerr1);
        }else if ("学校分布图".equals(tjlx)) {
            //获取临时图层--学校
            String url1 = tempLayerUrlMap.get("中小学分布图中小学");
            //获取图层图例（除文字标签）
            Layerr layerr1 = getLayerrByLayerNameUrl("中小学分布图中小学",url1);
            Layerr layerr2 = getLayerrByLayerNameUrl("中小学分布图铁路",url + "/map-datacenter/rest/maps/中小学分布图铁路");
            Layerr layerr3 = getLayerrByLayerNameUrl("中小学分布图道路",url + "/map-datacenter/rest/maps/中小学分布图道路");
            Layerr layerr4 = getLayerrByLayerNameUrl("中小学分布图水系",url + "/map-datacenter/rest/maps/中小学分布图水系");
            Layerr layerr5 = getLayerrByLayerNameUrl("中小学分布图建筑物",url + "/map-datacenter/rest/maps/中小学分布图建筑物");

            layerrs = Arrays.asList(layerr4, layerr3, layerr2, layerr5, layerr1);
        }else if ("避难场所分布图".equals(tjlx)) {
            //获取临时图层--城市避难场所（点）
            String url1 = tempLayerUrlMap.get("jc_emergcy_shelter");
            //获取图层图例（除文字标签）
            Layerr layerr1 = getLayerrByLayerNameUrl("应急避难场所分布图避难场所",url1);
            //获取临时图层--场所辐射范围
            String url2 = tempLayerUrlMap.get("sys_emergcy_shelter");
            Layerr layerr2 = getLayerrByLayerNameUrl("sys_emergcy_shelter@datacenter",url2);

            layerrs = Arrays.asList(layerr2, layerr1);
        }else if ("断层分布图".equals(tjlx)){
            //图例
            //获取临时图层--断层分布图最新活动时代
            String url1 = tempLayerUrlMap.get("断层分布图最新活动时代");
            //获取图层图例（除文字标签）
            Layerr layerr1 = getLayerrByLayerNameUrl("断层分布图最新活动时代",url1);

            Layerr layerr2 = getLayerrByLayerNameUrl("断层分布图道路",url + "/map-datacenter/rest/maps/断层分布图道路");//高速公路、国道(道路数据）、省道（道路数据）
            Layerr layerr3 = getLayerrByLayerNameUrl("断层分布图省界",url + "/map-datacenter/rest/maps/断层分布图省界");

            layerrs = Arrays.asList(layerr3, layerr2, layerr1);
        }else if ("地震构造图".equals(tjlx)){
            //图例
            String dcyxDataVersion = dataVersion.split(",")[1];//地层岩性版本号
            //查询空间范围内显示数据图例列表
            List<String> strings1 = getLegendListByTableFieldGeom("地震构造图地层年代","jc_stratum_lithology","values1",dcyxDataVersion,null,"Integer");
            //获取临时图层--地震构造图地层年代
            String url1 = tempLayerUrlMap.get("地震构造图地层年代");
//            Layerr layerr1 = new Layerr(url + "/map-datacenter/rest/maps/地震构造图地层年代",strings1);
            Layerr layerr1 = new Layerr(url1,strings1);

            //获取临时图层--地震构造图最新活动时代
            String url2 = tempLayerUrlMap.get("地震构造图最新活动时代");
            //获取图层图例（除文字标签）
            Layerr layerr2 = getLayerrByLayerNameUrl("地震构造图最新活动时代",url2);
            //获取临时图层--地震构造图断层性质
            String url3 = tempLayerUrlMap.get("地震构造图断层性质");
            Layerr layerr3 = getLayerrByLayerNameUrl("地震构造图断层性质",url3);

            Layerr layerr4 = getLayerrByLayerNameUrl("地震构造图水系",url + "/map-datacenter/rest/maps/地震构造图水系");
            Layerr layerr5 = getLayerrByLayerNameUrl("地震构造图水体",url + "/map-datacenter/rest/maps/地震构造图水体");
            Layerr layerr6 = getLayerrByLayerNameUrl("地震构造图省行政中心",url + "/map-datacenter/rest/maps/地震构造图省行政中心");
            Layerr layerr7 = getLayerrByLayerNameUrl("地震构造图市行政中心",url + "/map-datacenter/rest/maps/地震构造图市行政中心");
            Layerr layerr8 = getLayerrByLayerNameUrl("地震构造图县行政中心",url + "/map-datacenter/rest/maps/地震构造图县行政中心");
            Layerr layerr9 = getLayerrByLayerNameUrl("地震构造图省界",url + "/map-datacenter/rest/maps/地震构造图省界");

//            Layerr layerr10 = getLayerrByLayerNameUrl("地震构造图1970年前地震",url + "/map-datacenter/rest/maps/地震构造图1970年前地震");
//            Layerr layerr11 = getLayerrByLayerNameUrl("地震构造图1970年以来地震",url + "/map-datacenter/rest/maps/地震构造图1970年以来地震");

            layerrs = Arrays.asList(layerr5, layerr4, layerr9, layerr8, layerr7, layerr6, layerr3, layerr2);
            if(strings1.size()>0){
                layerrs = Arrays.asList(layerr5, layerr4, layerr9, layerr8, layerr7, layerr6, layerr3, layerr2, layerr1);
            }
        }else if ("历史地震分布图".equals(tjlx)){
            //图例
            //获取图层图例（除文字标签）
            Layerr layerr1 = getLayerrByLayerNameUrl("历史地震分布图历史地震",url + "/map-datacenter/rest/maps/历史地震分布图历史地震");

            //获取临时图层--历史地震分布图活动断裂
            String url2 = tempLayerUrlMap.get("历史地震分布图活动断裂");
            //获取图层图例（除文字标签）
            Layerr layerr2 = getLayerrByLayerNameUrl("历史地震分布图活动断裂",url2);
            Layerr layerr3 = getLayerrByLayerNameUrl("历史地震分布图行政区划",url + "/map-datacenter/rest/maps/历史地震分布图行政区划");

            layerrs = Arrays.asList(layerr3, layerr2, layerr1);
        }else if ("人员伤亡分布图".equals(tjlx)){
            //图例
            //获取临时图层--人员伤亡分布图
            String url1 = tempLayerUrlMap.get("sys_destory_alg");
            //获取图层图例（除文字标签）
            Layerr layerr1 = getLayerrByLayerNameUrl("sys_destory_alg@fxfzaqbz",url1);

            layerrs = Arrays.asList(layerr1);
        }else if ("地震灾害风险等级分布图".equals(tjlx)){
            //图例
            //获取临时图层--地震灾害风险等级分布图
            String url1 = tempLayerUrlMap.get("sys_destory_alg_level");
            //获取图层图例（除文字标签）
            Layerr layerr1 = getLayerrByLayerNameUrl("sys_destory_alg_level@fxfzaqbz",url1);

            layerrs = Arrays.asList(layerr1);
        }else if ("危险源避让分布图".equals(tjlx)){
            //图例
//            Layerr layerr1 = getLayerrByLayerNameUrl("sys_gasholder_br@fxfzaqbz",url + "/map-fxfzaqbz/rest/maps/sys_gasholder_br@fxfzaqbz");
//            Layerr layerr2 = getLayerrByLayerNameUrl("sys_gasholder@fxfzaqbz",url + "/map-fxfzaqbz/rest/maps/sys_gasholder@fxfzaqbz");
//            Layerr layerr3 = getLayerrByLayerNameUrl("sys_riskenterprisedata@fxfzypg",url + "/map-fxfzypg/rest/maps/sys_riskenterprisedata@fxfzypg");
//            Layerr layerr4 = getLayerrByLayerNameUrl("sys_gasstationdata@fxfzypg",url + "/map-fxfzypg/rest/maps/sys_gasstationdata@fxfzypg");
            //获取临时图层--危险源避让范围
            String url1 = tempLayerUrlMap.get("sys_gasholder_br");
            //获取图层图例（除文字标签）
            Layerr layerr1 = getLayerrByLayerNameUrl("sys_gasholder_br@fxfzaqbz",url1);
            //获取临时图层--储气罐
            String url2 = tempLayerUrlMap.get("sys_gasholder");
            //获取图层图例（除文字标签）
            Layerr layerr2 = getLayerrByLayerNameUrl("sys_gasholder@fxfzaqbz",url2);
            //获取临时图层--危化企业
            String url3 = tempLayerUrlMap.get("jc_dangerous_enterprise");
            //获取图层图例（除文字标签）
            Layerr layerr3 = getLayerrByLayerNameUrl("jc_dangerous_enterprise@datacenter",url3);
            //获取临时图层--加油站
            String url4 = tempLayerUrlMap.get("jc_lfcp_gas_station");
            //获取图层图例（除文字标签）
            Layerr layerr4 = getLayerrByLayerNameUrl("jc_lfcp_gas_station@datacenter",url4);

            layerrs = Arrays.asList(layerr1, layerr2, layerr3, layerr4);
        }else if ("地质灾害隐患点分布图".equals(tjlx)){
            //图例
//            Layerr layerr1 = getLayerrByLayerNameUrl("地质灾害隐患点分布图",url + "/map-datacenter/rest/maps/地质灾害隐患点分布图");
            //获取临时图层--地质灾害隐患点
            String url1 = tempLayerUrlMap.get("地质灾害隐患点分布图");
            //获取图层图例（除文字标签）
            Layerr layerr1 = getLayerrByLayerNameUrl("地质灾害隐患点分布图",url1);

            layerrs = Arrays.asList(layerr1);
        }else if ("易燃易爆危险源分布图".equals(tjlx)){
            //图例
//            Layerr layerr1 = getLayerrByLayerNameUrl("jc_lfcp_gas_station@datacenter",url + "/map-datacenter/rest/maps/jc_lfcp_gas_station@datacenter");
//            Layerr layerr2 = getLayerrByLayerNameUrl("jc_dangerous_enterprise@datacenter",url + "/map-datacenter/rest/maps/jc_dangerous_enterprise@datacenter");
//
//            layerrs = Arrays.asList(layerr1, layerr2);

            //获取临时图层--储气罐
            String url1 = tempLayerUrlMap.get("sys_gasholder");
            //获取图层图例（除文字标签）
            Layerr layerr1 = getLayerrByLayerNameUrl("sys_gasholder@fxfzaqbz",url1);
            //获取临时图层--危化企业
            String url2 = tempLayerUrlMap.get("jc_dangerous_enterprise");
            //获取图层图例（除文字标签）
            Layerr layerr2 = getLayerrByLayerNameUrl("jc_dangerous_enterprise@datacenter",url2);
            //获取临时图层--加油站
            String url3 = tempLayerUrlMap.get("jc_lfcp_gas_station");
            //获取图层图例（除文字标签）
            Layerr layerr3 = getLayerrByLayerNameUrl("jc_lfcp_gas_station@datacenter",url3);

            layerrs = Arrays.asList(layerr1, layerr2, layerr3);
        }else if ("人口分布图".equals(tjlx)){
            //图例
            Layerr layerr1 = getLayerrByLayerNameUrl("人口分布图",url + "/map-datacenter/rest/maps/人口分布图");

            layerrs = Arrays.asList(layerr1);
        }
        return layerrs;
    }

    private List<Layer> getLayer(String tjlx,Map<String,String> tempLayerUrlMap) {
        Properties configGroup = PropsHelper.loadProps("slw-config.properties");
        String url = configGroup.getProperty("supergraphRestTemplateUrl");
        List<Layer> layers = null;
        if ("物资储备库分布图".equals(tjlx)) {
//            String url1 = url + "/map-datacenter/rest/maps/jc_material_reserve@datacenter";
            //获取临时图层--物资储备库
            String url1 = tempLayerUrlMap.get("jc_material_reserve");
            Layer layer1 = new Layer("TILE","物资储备库", url1);

            String url15 = url + "/map-datacenter/rest/maps/中国行政区划图";
            Layer layer15 = new Layer("TILE","中国行政区划图", url15);
            layers = Arrays.asList(layer15, layer1);
        }else if ("医院分布图".equals(tjlx)) {
//            String url1 = url + "/map-datacenter/rest/maps/医院分布图医院";
            //获取临时图层--医院
            String url1 = tempLayerUrlMap.get("jc_rfcp_hospital");
            Layer layer1 = new Layer("TILE","医院分布图医院", url1);
            String url2 = url + "/map-datacenter/rest/maps/中小学分布图铁路";
            Layer layer2 = new Layer("TILE","中小学分布图铁路", url2);
            String url3 = url + "/map-datacenter/rest/maps/中小学分布图道路";
            Layer layer3 = new Layer("TILE","中小学分布图道路", url3);
            String url4 = url + "/map-datacenter/rest/maps/中小学分布图水系";
            Layer layer4 = new Layer("TILE", "中小学分布图水系", url4);
            String url5 = url + "/map-datacenter/rest/maps/中小学分布图建筑物";
            Layer layer5 = new Layer("TILE", "中小学分布图建筑物", url5);

            String url15 = url + "/map-datacenter/rest/maps/中国行政区划图";
            Layer layer15 = new Layer("TILE","中国行政区划图", url15);
            layers = Arrays.asList(layer15, layer4, layer5, layer3, layer2, layer1);
        }else if ("学校分布图".equals(tjlx)) {
//            String url1 = url + "/map-datacenter/rest/maps/中小学分布图中小学";
            //获取临时图层--学校
            String url1 = tempLayerUrlMap.get("中小学分布图中小学");
            Layer layer1 = new Layer("TILE","中小学分布图中小学", url1);
//            String url1_label = url + "/map-datacenter/rest/maps/jc_rfcp_school@datacenter";
            //获取临时图层--学校名称标签
            String url1_label = tempLayerUrlMap.get("jc_rfcp_school");
            Layer layer1_label = new Layer("TILE","中小学分布图中小学标签", url1_label);
            String url2 = url + "/map-datacenter/rest/maps/中小学分布图铁路";
            Layer layer2 = new Layer("TILE", "中小学分布图铁路", url2);
            String url3 = url + "/map-datacenter/rest/maps/中小学分布图道路";
            Layer layer3 = new Layer("TILE", "中小学分布图道路", url3);
            String url4 = url + "/map-datacenter/rest/maps/中小学分布图水系";
            Layer layer4 = new Layer("TILE","中小学分布图水系", url4);
            String url5 = url + "/map-datacenter/rest/maps/中小学分布图建筑物";
            Layer layer5 = new Layer("TILE","中小学分布图建筑物", url5);

            String url15 = url + "/map-datacenter/rest/maps/中国行政区划图";
            Layer layer15 = new Layer("TILE","中国行政区划图", url15);
            layers = Arrays.asList(layer15, layer4, layer5, layer3, layer2, layer1_label, layer1);
        }else if ("避难场所分布图".equals(tjlx)) {
//            String url1 = url + "/map-datacenter/rest/maps/应急避难场所分布图避难场所";
            //获取临时图层--城市避难场所（点）
            String url1 = tempLayerUrlMap.get("jc_emergcy_shelter");
            Layer layer1 = new Layer("TILE",  "应急避难场所分布图避难场所", url1);
//            String url2 = url + "/map-fxfzaqbz/rest/maps/sys_emergcy_shelter@fxfzaqbz";
            //获取临时图层--场所辐射范围
            String url2 = tempLayerUrlMap.get("sys_emergcy_shelter");
            Layer layer2 = new Layer("TILE",  "sys_emergcy_shelter@fxfzaqbz", url2);

            String url15 = url + "/map-datacenter/rest/maps/中国行政区划图";
            Layer layer15 = new Layer("TILE","中国行政区划图", url15);
            layers = Arrays.asList(layer15, layer2, layer1);
        }else if ("断层分布图".equals(tjlx)) {
//            String url1 = url + "/map-datacenter/rest/maps/断层分布图最新活动时代";
            String url1 = tempLayerUrlMap.get("断层分布图最新活动时代");
            Layer layer1 = new Layer("TILE","断层分布图最新活动时代", url1);

            String url2 = url + "/map-datacenter/rest/maps/断层分布图道路";
            Layer layer2 = new Layer("TILE", "断层分布图道路", url2);
            String url3 = url + "/map-datacenter/rest/maps/断层分布图省界";
            Layer layer3 = new Layer("TILE", "断层分布图省界", url3);

            String url15 = url + "/map-datacenter/rest/maps/中国行政区划图";
            Layer layer15 = new Layer("TILE","中国行政区划图", url15);
            layers = Arrays.asList(layer15, layer3, layer2, layer1);
        }else if ("地震构造图".equals(tjlx)){
            //图层
//            String url1 = url + "/map-datacenter/rest/maps/地震构造图地层年代";
            //获取临时图层--地震构造图地层年代
            String url1 = tempLayerUrlMap.get("地震构造图地层年代");
            Layer layer1 = new Layer("TILE","地震构造图地层年代", url1);

//            String url2 = url + "/map-datacenter/rest/maps/地震构造图最新活动时代";
            String url2 = tempLayerUrlMap.get("地震构造图最新活动时代");
            Layer layer2 = new Layer("TILE","地震构造图最新活动时代", url2);
//            String url3 = url + "/map-datacenter/rest/maps/地震构造图断层性质";
            String url3 = tempLayerUrlMap.get("地震构造图断层性质");
            Layer layer3 = new Layer("TILE","地震构造图断层性质", url3);

            String url4 = url + "/map-datacenter/rest/maps/地震构造图断层名称标签";
            Layer layer4 = new Layer("TILE","地震构造图断层名称标签", url4);
            String url5 = url + "/map-datacenter/rest/maps/地震构造图1970年以来地震";
            Layer layer5 = new Layer("TILE","地震构造图1970年以来地震", url5);
            String url6 = url + "/map-datacenter/rest/maps/地震构造图1970年前地震";
            Layer layer6 = new Layer("TILE","地震构造图1970年前地震", url6);

            String url7 = url + "/map-datacenter/rest/maps/地震构造图水系";
            Layer layer7 = new Layer("TILE","地震构造图水系", url7);
            String url8 = url + "/map-datacenter/rest/maps/地震构造图水体";
            Layer layer8 = new Layer("TILE","地震构造图水体", url8);
            String url9 = url + "/map-datacenter/rest/maps/地震构造图省行政中心";
            Layer layer9 = new Layer("TILE", "地震构造图省行政中心", url9);
            String url10 = url + "/map-datacenter/rest/maps/地震构造图省行政中心标签";
            Layer layer10 = new Layer("TILE", "地震构造图省行政中心标签", url10);
            String url11 = url + "/map-datacenter/rest/maps/地震构造图市行政中心";
            Layer layer11 = new Layer("TILE", "地震构造图市行政中心", url11);
            String url12 = url + "/map-datacenter/rest/maps/地震构造图县行政中心";
            Layer layer12 = new Layer("TILE", "地震构造图县行政中心", url12);
            String url13 = url + "/map-datacenter/rest/maps/地震构造图省界";
            Layer layer13 = new Layer("TILE", "地震构造图省界", url13);

            layers = Arrays.asList(layer8, layer7, layer13, layer12, layer11, layer10, layer9, layer4, layer3, layer2, layer1,layer5, layer6);
        }else if ("历史地震分布图".equals(tjlx)){
            //图层
            String url1 = url + "/map-datacenter/rest/maps/历史地震分布图历史地震";
            Layer layer1 = new Layer("TILE","历史地震分布图历史地震", url1);

//            String url2 = url + "/map-datacenter/rest/maps/历史地震分布图活动断裂";
            String url2 = tempLayerUrlMap.get("历史地震分布图活动断裂");
            Layer layer2 = new Layer("TILE","历史地震分布图活动断裂", url2);

            String url3 = url + "/map-datacenter/rest/maps/历史地震分布图行政区划";
            Layer layer3 = new Layer("TILE","历史地震分布图行政区划", url3);

            layers = Arrays.asList(layer3,layer2, layer1);
        }else if ("人员伤亡分布图".equals(tjlx)){
//            String url1 = url + "/map-fxfzaqbz/rest/maps/sys_destory_alg@fxfzaqbz";
            String url1 = tempLayerUrlMap.get("sys_destory_alg");
            Layer layer1 = new Layer("TILE","人员伤亡分布图", url1);

            String url15 = url + "/map-datacenter/rest/maps/中国行政区划图";
            Layer layer15 = new Layer("TILE","中国行政区划图", url15);
            layers = Arrays.asList(layer15, layer1);
        }else if ("地震灾害风险等级分布图".equals(tjlx)){
            String url1 = tempLayerUrlMap.get("sys_destory_alg_level");
            //图层
           // String url1 = url + "/map-fxfzaqbz/rest/maps/sys_destory_alg_level@fxfzaqbz";
            Layer layer1 = new Layer("TILE","地震灾害风险等级分布图", url1);

            String url15 = url + "/map-datacenter/rest/maps/中国行政区划图";
            Layer layer15 = new Layer("TILE","中国行政区划图", url15);
            layers = Arrays.asList(layer15, layer1);
        }else if ("危险源避让分布图".equals(tjlx)){
            //图层
//            String url1 = url + "/map-fxfzaqbz/rest/maps/sys_gasholder_br@fxfzaqbz";
            String url1 = tempLayerUrlMap.get("sys_gasholder_br");
            Layer layer1 = new Layer("TILE","危险源避让分布图（避让圆面）", url1);
//            String url2 = url + "/map-fxfzaqbz/rest/maps/sys_gasholder@fxfzaqbz";
            String url2 = tempLayerUrlMap.get("sys_gasholder");
            Layer layer2 = new Layer("TILE",  "危险源避让分布图（储气罐点）", url2);
//            String url3 = url + "/map-fxfzypg/rest/maps/jc_dangerous_enterprise@datacenter";
            String url3 = tempLayerUrlMap.get("jc_dangerous_enterprise");
            Layer layer3 = new Layer("TILE","危化企业", url3);
//            String url4 = url + "/map-fxfzypg/rest/maps/jc_lfcp_gas_station@datacenter";
            String url4 = tempLayerUrlMap.get("jc_lfcp_gas_station");
            Layer layer4 = new Layer("TILE", "加油（加气）站", url4);

            String url15 = url + "/map-datacenter/rest/maps/中国行政区划图";
            Layer layer15 = new Layer("TILE","中国行政区划图", url15);
            layers = Arrays.asList(layer15, layer1, layer2, layer3, layer4);
        }else if ("地质灾害隐患点分布图".equals(tjlx)){
            //图层
//            String url1 = url + "/map-datacenter/rest/maps/地质灾害隐患点分布图";
            //获取临时图层--地质灾害隐患点
            String url1 = tempLayerUrlMap.get("地质灾害隐患点分布图");
            Layer layer1 = new Layer("TILE","地质灾害隐患点分布图", url1);

            String url15 = url + "/map-datacenter/rest/maps/中国行政区划图";
            Layer layer15 = new Layer("TILE","中国行政区划图", url15);
            layers = Arrays.asList(layer15, layer1);
        }else if ("易燃易爆危险源分布图".equals(tjlx)){
            //图层
//            String url1 = url + "/map-datacenter/rest/maps/jc_lfcp_gas_station@datacenter";
//            Layer layer1 = new Layer("TILE","加油（加气）站", url1);
//            String url2 = url + "/map-datacenter/rest/maps/jc_dangerous_enterprise@datacenter";
//            Layer layer2 = new Layer("TILE","危化企业", url2);
//
//            String url15 = url + "/map-datacenter/rest/maps/中国行政区划图";
//            Layer layer15 = new Layer("TILE","中国行政区划图", url15);
//            layers = Arrays.asList(layer15, layer1, layer2);

//            String url1 = url + "/map-fxfzaqbz/rest/maps/sys_gasholder@fxfzaqbz";
            String url1 = tempLayerUrlMap.get("sys_gasholder");
            Layer layer1 = new Layer("TILE",  "危险源避让分布图（储气罐点）", url1);
//            String url2 = url + "/map-fxfzypg/rest/maps/jc_dangerous_enterprise@datacenter";
            String url2 = tempLayerUrlMap.get("jc_dangerous_enterprise");
            Layer layer2 = new Layer("TILE","危化企业", url2);
//            String url3 = url + "/map-fxfzypg/rest/maps/jc_lfcp_gas_station@datacenter";
            String url3 = tempLayerUrlMap.get("jc_lfcp_gas_station");
            Layer layer3 = new Layer("TILE", "加油（加气）站", url3);

            String url15 = url + "/map-datacenter/rest/maps/中国行政区划图";
            Layer layer15 = new Layer("TILE","中国行政区划图", url15);
            layers = Arrays.asList(layer15, layer1, layer2, layer3);
        }else if ("人口分布图".equals(tjlx)){
            //图层
//            String url1 = url + "/map-datacenter/rest/maps/人口分布图";
            //获取临时图层--人口分布图
            String url1 = tempLayerUrlMap.get("人口分布图");
            Layer layer1 = new Layer("TILE","人口分布图", url1);

            String url15 = url + "/map-datacenter/rest/maps/中国行政区划图";
            Layer layer15 = new Layer("TILE","中国行政区划图", url15);
            layers = Arrays.asList(layer15, layer1);
        }
        return layers;
    }

    private String clTitle(String titleNum) {
        if ("13".equals(titleNum)) {
            return "物资储备库分布图";
        }
        if ("8".equals(titleNum)) {
            return "医院分布图";
        }
        if ("12".equals(titleNum)) {
            return "避难场所分布图";
        }
        if ("7".equals(titleNum)) {
            return "学校分布图";
        }
        return "类型不存在";
    }

    @Override
    public List<Map<String, Object>> getSupergraph() {
        List<ProfessionMap> professionMapList = supergraphRepository.getSupergraph();
        List<ProfessionMap> wzcbName = new ArrayList<>();
        List<ProfessionMap> yyName = new ArrayList<>();
        List<ProfessionMap> dzyjssfzName = new ArrayList<>();
        List<ProfessionMap> bncsName = new ArrayList<>();
        List<ProfessionMap> xxName = new ArrayList<>();
        if (professionMapList != null) {

            for (ProfessionMap professionMap : professionMapList) {
                if ("13".equals(professionMap.getType())) {
                    wzcbName.add(professionMap);
                }
                if ("8".equals(professionMap.getType())) {
                    yyName.add(professionMap);
                }
                if ("11".equals(professionMap.getType())) {
                    dzyjssfzName.add(professionMap);
                }
                if ("12".equals(professionMap.getType())) {
                    bncsName.add(professionMap);
                }
                if ("7".equals(professionMap.getType())) {
                    xxName.add(professionMap);
                }
            }
        }
        String wzfbt = "物资储备库分布图";
        String yyfbt = "医院分布图";
        String bncsfbt = "避难场所分布图";
        String xxfbt = "学校分布图";
        List<Map<String, Object>> list = new ArrayList<>();
        Map<String, Object> wzcbMap = new HashMap<>();
        wzcbMap.put("tjlx", wzfbt);
        wzcbMap.put("tjmb", wzcbName);
        wzcbMap.put("id", "13");
        wzcbMap.put("dataVersion", "");
        wzcbMap.put("num", "wzcbk");
        wzcbMap.put("xzmb", "");
        list.add(wzcbMap);

        Map<String, Object> yyMap = new HashMap<>();
        yyMap.put("tjlx", yyfbt);
        yyMap.put("tjmb", yyName);
        yyMap.put("id", "8");
        yyMap.put("dataVersion", "");
        yyMap.put("num", "yy1");
        yyMap.put("xzmb", "");
        list.add(yyMap);

        Map<String, Object> bncsMap = new HashMap<>();
        bncsMap.put("tjlx", bncsfbt);
        bncsMap.put("tjmb", bncsName);
        bncsMap.put("id", "12");
        bncsMap.put("dataVersion", "");
        bncsMap.put("num", "csbncs");//城市避难场所（点）
        bncsMap.put("xzmb", "");
        list.add(bncsMap);

        Map<String, Object> xxMap = new HashMap<>();
        xxMap.put("tjlx", xxfbt);
        xxMap.put("tjmb", xxName);
        xxMap.put("id", "7");
        xxMap.put("dataVersion", "");
        xxMap.put("num", "xxb");
        xxMap.put("xzmb", "");
        list.add(xxMap);
        return list;
    }


    @Override
    public RestResponse sourceOfDangerBr(SourceOfDangerBrVO sourceOfDangerBrVO) throws InterruptedException {
        //获取超图服务token
        String token = hypergraphService.getToken();
        if (PlatformObjectUtils.isEmpty(token)) {
            return RestResponse.fail("缺少超图服务token");
        }
        RestResponse restResponse = null;
        //数据版本号：储气罐,加油站,危化企业
        String dataVersion = sourceOfDangerBrVO.getCqgDataVersion() + "," + sourceOfDangerBrVO.getJyzDataVersion() + "," + sourceOfDangerBrVO.getWhqyDataVersion();
        //删除危险源避让范围数据
        gasholderService.deleteGasholderBr(sourceOfDangerBrVO.getIaId(),dataVersion);
        //根据版本 省市区获取业务数据
        List<Gasholder> ywData = gasholderService.getDataBySSQAndVersion(sourceOfDangerBrVO);
        //加油站、危化企业
        Map<String, Object> paramMap = new HashMap<>();
        Properties configGroup1 = PropsHelper.loadProps("slw-config.properties");
        String lxUrl = configGroup1.getProperty("restTemplateUrl") + "/datacenter/house/getJcd";
        //  paramMap.put("list",sourceOfDangerBrVO.getList());
        paramMap.put("whqydataVersion", sourceOfDangerBrVO.getWhqyDataVersion());
        paramMap.put("jyzdataVersion", sourceOfDangerBrVO.getJyzDataVersion());
        ResponseEntity<String> responseEntity = restTemplateUtil.sendPostHttpRequest1(lxUrl, paramMap);
        List<RefugeResponse> responses = JSONObject.parseArray(responseEntity.getBody(), RefugeResponse.class);
        for (RefugeResponse respons : responses) {
            GasholderBrVO gasholderBrVO = new GasholderBrVO();
            gasholderBrVO.setId(UUIDGenerator.getUUID());
            gasholderBrVO.setGaLatitude(respons.getLatitude());
            gasholderBrVO.setGaLongitude(respons.getLongitude());
            gasholderBrVO.setIaId(sourceOfDangerBrVO.getIaId());
            if (respons.getType().equals("1")) {
                gasholderBrVO.setYxbj(50.0);
            } else if (respons.getType().equals("2")) {
                gasholderBrVO.setYxbj(100.0);
            } else if (respons.getType().equals("3")) {
                gasholderBrVO.setYxbj(200.0);
            }
            Polygon circle = createCircle(gasholderBrVO.getGaLongitude(), gasholderBrVO.getGaLatitude(), gasholderBrVO.getYxbj());
            String string = circle.toString();
            gasholderBrVO.setGeom(string);
            gasholderBrVO.setDelFlag("0");
            gasholderBrVO.setDataVersion(dataVersion);
            gasholderService.saveGasholderBr(gasholderBrVO);
        }
        //储气罐
        if (ywData == null) {
            return RestResponse.fail("该省市区下未找到此版本的储气罐数据,请添加对应数据");
        }
        for (Gasholder ywDatum : ywData) {
            GasholderBrVO gasholderBrVO = new GasholderBrVO();
            gasholderBrVO.setId(UUIDGenerator.getUUID());
            gasholderBrVO.setGcrj(ywDatum.getGaGcrj());
            gasholderBrVO.setGaLatitude(ywDatum.getGaLatitude());
            gasholderBrVO.setGaLongitude(ywDatum.getGaLongitude());
            gasholderBrVO.setIaId(sourceOfDangerBrVO.getIaId());
            if (ywDatum.getGaGcrj() >= 0.0 && ywDatum.getGaGcrj() < 200.0) {
                gasholderBrVO.setYxbj(50.0);
            } else if (ywDatum.getGaGcrj() >= 200.0 && ywDatum.getGaGcrj() < 500.0) {
                gasholderBrVO.setYxbj(50.0);
            } else if (ywDatum.getGaGcrj() >= 500.0 && ywDatum.getGaGcrj() < 1000.0) {
                gasholderBrVO.setYxbj(100.0);
            } else if (ywDatum.getGaGcrj() >= 1000.0 && ywDatum.getGaGcrj() < 3000) {
                gasholderBrVO.setYxbj(200.0);
            } else if (ywDatum.getGaGcrj() >= 3000) {
                gasholderBrVO.setYxbj(200.0);
            }

            Polygon circle = createCircle(ywDatum.getGaLongitude(), ywDatum.getGaLatitude(), gasholderBrVO.getYxbj());
            String string = circle.toString();
            gasholderBrVO.setGeom(string);
            gasholderBrVO.setDelFlag("0");
            gasholderBrVO.setDataVersion(dataVersion);
            //根据经度
            gasholderService.saveGasholderBr(gasholderBrVO);
        }
        //刷新指定超图工作空间数据源数据集
        hypergraphService.getWorkspaceReload("sys_gasholder_br");

        Properties configGroup = PropsHelper.loadProps("slw-config.properties");
        String url = configGroup.getProperty("supergraphRestTemplateUrl");
        List<District> list = sourceOfDangerBrVO.getList();
        List<String> codes = new ArrayList<>();

        String centerX = "";
        String centerY = "";
        String leftX = "";
        String leftY = "";
        String rightX = "";
        String rightY = "";
        int level = 0;
        if (StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getCenterX())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getCenterY())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getLeftX())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getLeftY())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getRightX())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getRightY())) {
            centerX = sourceOfDangerBrVO.getCircleVO().getCenterX();
            centerY = sourceOfDangerBrVO.getCircleVO().getCenterY();
            leftX = sourceOfDangerBrVO.getCircleVO().getLeftX();
            leftY = sourceOfDangerBrVO.getCircleVO().getLeftY();
            rightX = sourceOfDangerBrVO.getCircleVO().getRightX();
            rightY = sourceOfDangerBrVO.getCircleVO().getRightY();
            level = getLevel(Double.valueOf(leftX), Double.valueOf(leftY), Double.valueOf(rightX), Double.valueOf(rightY),null);
        } else {
            for (District district : list) {
                String district1 = null;
                //北京市，上海市，天津市，重庆市
                if ("北京市".equals(district.getProvince()) || "上海市".equals(district.getProvince()) || "天津市".equals(district.getProvince()) || "重庆市".equals(district.getProvince())) {
                    district1 = district.getCity() + "-" + district.getPrefecture();
                } else {
                    district1 = district.getProvince() + "-" + district.getCity() + "-" + district.getPrefecture();
                }
                String code = orgDivisionRepository.getCodeByTaskDistrict(district1);
                codes.add(code);
            }

//        List<String> strings = list.stream().map(District::getPrefecture).collect(Collectors.toList());
            String extent = districtBoundaryRepository.getExtent(codes);
            String center = districtBoundaryRepository.getcenter(codes);
            String[] split = extent.substring(4, extent.length() - 1).split(",");
            String[] s1 = split[0].split(" ");
            String[] s2 = split[1].split(" ");
            leftX = s1[0];
            leftY = s1[1];
            rightX = s2[0];
            rightY = s2[1];
            level = getLevel(Double.valueOf(leftX), Double.valueOf(leftY), Double.valueOf(rightX), Double.valueOf(rightY),null);
            String[] s = center.substring(6, center.length() - 1).split(" ");
            centerX = s[0];
            centerY = s[1];
        }

        //获取图层图例
        TjVO tjVO=new TjVO("危险源避让分布图",sourceOfDangerBrVO.getTjmb(),dataVersion,sourceOfDangerBrVO.getTjbt(),"0");
        Map<String,String> tempLayerUrlMap = getTempLayerUrlMapByTjVO(tjVO);
        List<Layer> layers = getLayer(tjVO.getTjlx(),tempLayerUrlMap);
        List<Layerr> layerrs = getLayerrs(tjVO.getTjlx(),tempLayerUrlMap,tjVO.getDataVersion());

        //获取Web打印出图模板列表
        List<TemplateEntity> templateEntityList = hypergraphService.getWebprintingLayoutsList();
        //根据参数设置请求体
        String jsonString = getRequestVOJsonStringByTjmb(sourceOfDangerBrVO.getTjmb(),templateEntityList,sourceOfDangerBrVO.getTjbt(),sourceOfDangerBrVO.getZtdw(),layerrs,layers,Double.valueOf(centerX),Double.valueOf(centerY),Double.valueOf(leftX),Double.valueOf(leftY),Double.valueOf(rightX),Double.valueOf(rightY),level,false);
        Map map = JSONObject.parseObject(jsonString, Map.class);
        String urll = url + "/webprinting/rest/webprinting/v1/jobs.json?token=" + token;
        ResponseEntity<String> stringResponseEntity = restTemplateUtil.sendPostHttpRequest2(urll, map);
        String body = stringResponseEntity.getBody();
        List<ResponseVO> responseVO = JSON.parseArray(body, ResponseVO.class);
        String path = "";
        String imageId = "";
        Map<String, Object> responseMap = new HashMap<>();
        if (responseVO != null || responseVO.size() > 0) {
            path = responseVO.get(0).getPath() + "/" + "result";
            //    String dateDir = new SimpleDateFormat("/yyyy/MM/dd").format(new Date());
            String savePath = localDir;
            path = path.replace("@", "%40");
            System.out.println("路径  " + path);
            String path2 = responseVO.get(0).getPath() + ".rjson";
            Map<String, Object> map2 = new HashMap<>();
            boolean flag = true;
            while (flag) {
                ResponseEntity<String> responseEntity1 = restTemplateUtil.sendHttpRequest3(path2, map2);
                String body1 = responseEntity1.getBody();
                String[] split1 = body1.split("status");
                if (split1[1].contains("ERROR")) {
                    log.error("超图服务打印失败");
                    return RestResponse.fail("超图服务打印失败");
                }
                if (split1[1].contains("FINISHED")){
                    flag = false;
                    continue;
            }
                Thread.sleep(500);
            }
            restResponse = downloadsFile.downloadByUrl(path, savePath);
            imageId = restResponse.getData().toString();
            AttachmentInfoEntity attach = attachmentInfoService.getAttach(imageId);
            responseMap.put("attach", attach);
            responseMap.put("count", "危险源避让分布图");
            responseMap.put("dataVersion", "储气罐数据版本为:" + sourceOfDangerBrVO.getCqgDataVersion() + "<br/>加油站数据版本为:" + sourceOfDangerBrVO.getJyzDataVersion() + "<br/>危化企业数据版本为:" + sourceOfDangerBrVO.getWhqyDataVersion());
            responseMap.put("title", "");
        }
        File file = new File(localDir);
        File[] files = file.listFiles();
        for (File file1 : files) {
            if (file1.isFile()) {
                file1.delete();
            }
        }
        restResponse = RestResponse.succeed(responseMap);
        return restResponse;
    }

    @Override
    public RestResponse hazardPoint(SourceOfDangerBrVO sourceOfDangerBrVO) throws InterruptedException {
        //获取超图服务token
        String token = hypergraphService.getToken();
        if (PlatformObjectUtils.isEmpty(token)) {
            return RestResponse.fail("缺少超图服务token");
        }
        RestResponse restResponse = null;
        Properties configGroup = PropsHelper.loadProps("slw-config.properties");
        String url = configGroup.getProperty("supergraphRestTemplateUrl");
        String dataVersion = sourceOfDangerBrVO.getDzzhDataVersion();//地质灾害隐患点版本号
        List<District> list = sourceOfDangerBrVO.getList();
        List<String> codes = new ArrayList<>();


        String centerX = "";
        String centerY = "";
        String leftX = "";
        String leftY = "";
        String rightX = "";
        String rightY = "";
        int level = 0;
        if (StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getCenterX())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getCenterY())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getLeftX())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getLeftY())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getRightX())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getRightY())) {
            centerX = sourceOfDangerBrVO.getCircleVO().getCenterX();
            centerY = sourceOfDangerBrVO.getCircleVO().getCenterY();
            leftX = sourceOfDangerBrVO.getCircleVO().getLeftX();
            leftY = sourceOfDangerBrVO.getCircleVO().getLeftY();
            rightX = sourceOfDangerBrVO.getCircleVO().getRightX();
            rightY = sourceOfDangerBrVO.getCircleVO().getRightY();
            level = getLevel(Double.valueOf(leftX), Double.valueOf(leftY), Double.valueOf(rightX), Double.valueOf(rightY),null);
        } else {
            for (District district : list) {
                String district1 = null;
                //北京市，上海市，天津市，重庆市
                if ("北京市".equals(district.getProvince()) || "上海市".equals(district.getProvince()) || "天津市".equals(district.getProvince()) || "重庆市".equals(district.getProvince())) {
                    district1 = district.getCity() + "-" + district.getPrefecture();
                } else {
                    district1 = district.getProvince() + "-" + district.getCity() + "-" + district.getPrefecture();
                }
                String code = orgDivisionRepository.getCodeByTaskDistrict(district1);
                codes.add(code);
            }

//        List<String> strings = list.stream().map(District::getPrefecture).collect(Collectors.toList());
            String extent = districtBoundaryRepository.getExtent(codes);
            String center = districtBoundaryRepository.getcenter(codes);
            String[] split = extent.substring(4, extent.length() - 1).split(",");
            String[] s1 = split[0].split(" ");
            String[] s2 = split[1].split(" ");
            leftX = s1[0];
            leftY = s1[1];
            rightX = s2[0];
            rightY = s2[1];
            level = getLevel(Double.valueOf(leftX), Double.valueOf(leftY), Double.valueOf(rightX), Double.valueOf(rightY),null);
            String[] s = center.substring(6, center.length() - 1).split(" ");
            centerX = s[0];
            centerY = s[1];
        }

        //获取图层图例
        TjVO tjVO=new TjVO("地质灾害隐患点分布图",sourceOfDangerBrVO.getTjmb(),dataVersion,sourceOfDangerBrVO.getTjbt(),"0");
        Map<String,String> tempLayerUrlMap = getTempLayerUrlMapByTjVO(tjVO);
        List<Layer> layers = getLayer(tjVO.getTjlx(),tempLayerUrlMap);
        List<Layerr> layerrs = getLayerrs(tjVO.getTjlx(),tempLayerUrlMap,tjVO.getDataVersion());

        //获取Web打印出图模板列表
        List<TemplateEntity> templateEntityList = hypergraphService.getWebprintingLayoutsList();
        //根据参数设置请求体
        String jsonString = getRequestVOJsonStringByTjmb(sourceOfDangerBrVO.getTjmb(),templateEntityList,sourceOfDangerBrVO.getTjbt(),sourceOfDangerBrVO.getZtdw(),layerrs,layers,Double.valueOf(centerX),Double.valueOf(centerY),Double.valueOf(leftX),Double.valueOf(leftY),Double.valueOf(rightX),Double.valueOf(rightY),level,false);
        Map map = JSONObject.parseObject(jsonString, Map.class);
        String urll = url + "/webprinting/rest/webprinting/v1/jobs.json?token=" + token;
        ResponseEntity<String> stringResponseEntity = restTemplateUtil.sendPostHttpRequest2(urll, map);
        String body = stringResponseEntity.getBody();
        List<ResponseVO> responseVO = JSON.parseArray(body, ResponseVO.class);
        String path = "";
        String imageId = "";
        Map<String, Object> responseMap = new HashMap<>();
        if (responseVO != null || responseVO.size() > 0) {
            path = responseVO.get(0).getPath() + "/" + "result";
            //    String dateDir = new SimpleDateFormat("/yyyy/MM/dd").format(new Date());
            String savePath = localDir;
            path = path.replace("@", "%40");
            System.out.println("路径  " + path);
            String path2 = responseVO.get(0).getPath() + ".rjson";
            Map<String, Object> map2 = new HashMap<>();
            boolean flag = true;
            while (flag) {
                ResponseEntity<String> responseEntity = restTemplateUtil.sendHttpRequest3(path2, map2);
                String body1 = responseEntity.getBody();
                String[] split1 = body1.split("status");
                if (split1[1].contains("ERROR")) {
                    log.error("超图服务打印失败");
                    return RestResponse.fail("超图服务打印失败");
                }
                if (split1[1].contains("FINISHED")){
                    flag = false;
                    continue;
                }
                Thread.sleep(500);
            }
            restResponse = downloadsFile.downloadByUrl(path, savePath);
            imageId = restResponse.getData().toString();
            AttachmentInfoEntity attach = attachmentInfoService.getAttach(imageId);
            responseMap.put("attach", attach);
            responseMap.put("count", "地质灾害隐患点分布图");
            responseMap.put("title", "");
            responseMap.put("dataVersion", "地震灾害危险点数据版本为:" + dataVersion);

        }
        File file = new File(localDir);
        File[] files = file.listFiles();
        for (File file1 : files) {
            if (file1.isFile()) {
                file1.delete();
            }
        }
        restResponse = RestResponse.succeed(responseMap);
        return restResponse;
    }

    @Override
    public RestResponse sourceOfDanger(SourceOfDangerBrVO sourceOfDangerBrVO) throws InterruptedException {

        //获取超图服务token
        String token = hypergraphService.getToken();
        if (PlatformObjectUtils.isEmpty(token)) {
            return RestResponse.fail("缺少超图服务token");
        }
        String cqgDataVersion = sourceOfDangerBrVO.getCqgDataVersion();//储气罐版本号
        String jyzDataVersion = sourceOfDangerBrVO.getJyzDataVersion();//加油站版本号
        String whqyDataVersion = sourceOfDangerBrVO.getWhqyDataVersion();//危化企业版本号
        Properties configGroup = PropsHelper.loadProps("slw-config.properties");
        String url = configGroup.getProperty("supergraphRestTemplateUrl");
        List<District> list = sourceOfDangerBrVO.getList();
        List<String> codes = new ArrayList<>();
        String centerX = "";
        String centerY = "";
        String leftX = "";
        String leftY = "";
        String rightX = "";
        String rightY = "";
        int level = 0;
        if (StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getCenterX())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getCenterY())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getLeftX())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getLeftY())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getRightX())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getRightY())) {
            centerX = sourceOfDangerBrVO.getCircleVO().getCenterX();
            centerY = sourceOfDangerBrVO.getCircleVO().getCenterY();
            leftX = sourceOfDangerBrVO.getCircleVO().getLeftX();
            leftY = sourceOfDangerBrVO.getCircleVO().getLeftY();
            rightX = sourceOfDangerBrVO.getCircleVO().getRightX();
            rightY = sourceOfDangerBrVO.getCircleVO().getRightY();
            level = getLevel(Double.valueOf(leftX), Double.valueOf(leftY), Double.valueOf(rightX), Double.valueOf(rightY),null);
        } else {
            for (District district : list) {
                String district1 = null;
                //北京市，上海市，天津市，重庆市
                if ("北京市".equals(district.getProvince()) || "上海市".equals(district.getProvince()) || "天津市".equals(district.getProvince()) || "重庆市".equals(district.getProvince())) {
                    district1 = district.getCity() + "-" + district.getPrefecture();
                } else {
                    district1 = district.getProvince() + "-" + district.getCity() + "-" + district.getPrefecture();
                }
                String code = orgDivisionRepository.getCodeByTaskDistrict(district1);
                codes.add(code);
            }

//        List<String> strings = list.stream().map(District::getPrefecture).collect(Collectors.toList());
            String extent = districtBoundaryRepository.getExtent(codes);
            String center = districtBoundaryRepository.getcenter(codes);
            String[] split = extent.substring(4, extent.length() - 1).split(",");
            String[] s1 = split[0].split(" ");
            String[] s2 = split[1].split(" ");
            leftX = s1[0];
            leftY = s1[1];
            rightX = s2[0];
            rightY = s2[1];
            level = getLevel(Double.valueOf(leftX), Double.valueOf(leftY), Double.valueOf(rightX), Double.valueOf(rightY),null);
            String[] s = center.substring(6, center.length() - 1).split(" ");
            centerX = s[0];
            centerY = s[1];
        }

        RestResponse restResponse = null;

        //数据版本号：储气罐,加油站,危化企业
        String dataVersion = sourceOfDangerBrVO.getCqgDataVersion() + "," + sourceOfDangerBrVO.getJyzDataVersion() + "," + sourceOfDangerBrVO.getWhqyDataVersion();
        //获取图层图例
        TjVO tjVO=new TjVO("易燃易爆危险源分布图",sourceOfDangerBrVO.getTjmb(),dataVersion,sourceOfDangerBrVO.getTjbt(),"0");
        Map<String,String> tempLayerUrlMap = getTempLayerUrlMapByTjVO(tjVO);
        List<Layer> layers = getLayer(tjVO.getTjlx(),tempLayerUrlMap);
        List<Layerr> layerrs = getLayerrs(tjVO.getTjlx(),tempLayerUrlMap,tjVO.getDataVersion());

        //获取Web打印出图模板列表
        List<TemplateEntity> templateEntityList = hypergraphService.getWebprintingLayoutsList();
        //根据参数设置请求体
        String jsonString = getRequestVOJsonStringByTjmb(sourceOfDangerBrVO.getTjmb(),templateEntityList,sourceOfDangerBrVO.getTjbt(),sourceOfDangerBrVO.getZtdw(),layerrs,layers,Double.valueOf(centerX),Double.valueOf(centerY),Double.valueOf(leftX),Double.valueOf(leftY),Double.valueOf(rightX),Double.valueOf(rightY),level,false);
        Map map = JSONObject.parseObject(jsonString, Map.class);
        String urll = url + "/webprinting/rest/webprinting/v1/jobs.json?token=" + token;
        ResponseEntity<String> stringResponseEntity = restTemplateUtil.sendPostHttpRequest2(urll, map);
        String body = stringResponseEntity.getBody();
        List<ResponseVO> responseVO = JSON.parseArray(body, ResponseVO.class);
        String path = "";
        String imageId = "";
        Map<String, Object> responseMap = new HashMap<>();
        if (responseVO != null || responseVO.size() > 0) {
            path = responseVO.get(0).getPath() + "/" + "result";
            //    String dateDir = new SimpleDateFormat("/yyyy/MM/dd").format(new Date());
            String savePath = localDir;
            path = path.replace("@", "%40");
            System.out.println("路径  " + path);
            String path2 = responseVO.get(0).getPath() + ".rjson";
            Map<String, Object> map2 = new HashMap<>();
            boolean flag = true;
            while (flag) {
                ResponseEntity<String> responseEntity = restTemplateUtil.sendHttpRequest3(path2, map2);
                String body1 = responseEntity.getBody();
                String[] split1 = body1.split("status");
                if (split1[1].contains("ERROR")) {
                    log.error("超图服务打印失败");
                    return RestResponse.fail("超图服务打印失败");
                }
                if (split1[1].contains("FINISHED")){
                    flag = false;
                    continue;
                }
                Thread.sleep(500);
            }
            restResponse = downloadsFile.downloadByUrl(path, savePath);
            imageId = restResponse.getData().toString();
            AttachmentInfoEntity attach = attachmentInfoService.getAttach(imageId);
            responseMap.put("attach", attach);
            responseMap.put("count", "危险源分布图");
            responseMap.put("dataVersion", "储气罐数据版本为:" + sourceOfDangerBrVO.getCqgDataVersion() + "<br/>加油站数据版本为:" + sourceOfDangerBrVO.getJyzDataVersion() + "<br/>危化企业数据版本为:" + sourceOfDangerBrVO.getWhqyDataVersion());
        }
        File file = new File(localDir);
        File[] files = file.listFiles();
        for (File file1 : files) {
            if (file1.isFile()) {
                file1.delete();
            }
        }
        restResponse = RestResponse.succeed(responseMap);
        return restResponse;
    }

    @Override
    public RestResponse faultage(SourceOfDangerBrVO sourceOfDangerBrVO) throws InterruptedException {
        faultService.saveFault(sourceOfDangerBrVO.getIaId(),sourceOfDangerBrVO.getDcDataVersion());
        RestResponse restResponse = null;
        //获取超图服务token
        String token = hypergraphService.getToken();
        if (PlatformObjectUtils.isEmpty(token)) {
            return RestResponse.fail("缺少超图服务token");
        }
        Properties configGroup = PropsHelper.loadProps("slw-config.properties");
        String url = configGroup.getProperty("supergraphRestTemplateUrl");
        List<District> list = sourceOfDangerBrVO.getList();
        List<String> codes = new ArrayList<>();
        String centerX = "";
        String centerY = "";
        String leftX = "";
        String leftY = "";
        String rightX = "";
        String rightY = "";
        int level = 0;
        if (StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getCenterX())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getCenterY())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getLeftX())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getLeftY())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getRightX())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getRightY())) {
            centerX = sourceOfDangerBrVO.getCircleVO().getCenterX();
            centerY = sourceOfDangerBrVO.getCircleVO().getCenterY();
            leftX = sourceOfDangerBrVO.getCircleVO().getLeftX();
            leftY = sourceOfDangerBrVO.getCircleVO().getLeftY();
            rightX = sourceOfDangerBrVO.getCircleVO().getRightX();
            rightY = sourceOfDangerBrVO.getCircleVO().getRightY();
            level = getLevel(Double.valueOf(leftX), Double.valueOf(leftY), Double.valueOf(rightX), Double.valueOf(rightY),null);
        } else {
            for (District district : list) {
                String district1 = null;
                //北京市，上海市，天津市，重庆市
                if ("北京市".equals(district.getProvince()) || "上海市".equals(district.getProvince()) || "天津市".equals(district.getProvince()) || "重庆市".equals(district.getProvince())) {
                    district1 = district.getCity() + "-" + district.getPrefecture();
                } else {
                    district1 = district.getProvince() + "-" + district.getCity() + "-" + district.getPrefecture();
                }
                String code = orgDivisionRepository.getCodeByTaskDistrict(district1);
                codes.add(code);
            }

//        List<String> strings = list.stream().map(District::getPrefecture).collect(Collectors.toList());
            String extent = districtBoundaryRepository.getExtent(codes);
            String center = districtBoundaryRepository.getcenter(codes);
            String[] split = extent.substring(4, extent.length() - 1).split(",");
            String[] s1 = split[0].split(" ");
            String[] s2 = split[1].split(" ");
            leftX = s1[0];
            leftY = s1[1];
            rightX = s2[0];
            rightY = s2[1];
            level = getLevel(Double.valueOf(leftX), Double.valueOf(leftY), Double.valueOf(rightX), Double.valueOf(rightY),null);
            String[] s = center.substring(6, center.length() - 1).split(" ");
            centerX = s[0];
            centerY = s[1];
        }

        //获取图层图例
        TjVO tjVO=new TjVO("断层分布图",sourceOfDangerBrVO.getTjmb(),sourceOfDangerBrVO.getDcDataVersion(),sourceOfDangerBrVO.getTjbt(),"0");
        Map<String,String> tempLayerUrlMap = getTempLayerUrlMapByTjVO(tjVO);
        List<Layer> layers = getLayer(tjVO.getTjlx(),tempLayerUrlMap);
        List<Layerr> layerrs = getLayerrs(tjVO.getTjlx(),tempLayerUrlMap,tjVO.getDataVersion());

        //获取Web打印出图模板列表
        List<TemplateEntity> templateEntityList = hypergraphService.getWebprintingLayoutsList();
        //根据参数设置请求体
        String jsonString = getRequestVOJsonStringByTjmb(sourceOfDangerBrVO.getTjmb(),templateEntityList,sourceOfDangerBrVO.getTjbt(),sourceOfDangerBrVO.getZtdw(),layerrs,layers,Double.valueOf(centerX),Double.valueOf(centerY),Double.valueOf(leftX),Double.valueOf(leftY),Double.valueOf(rightX),Double.valueOf(rightY),level,false);
        Map map = JSONObject.parseObject(jsonString, Map.class);
        String urll = url + "/webprinting/rest/webprinting/v1/jobs.json?token=" + token;
        ResponseEntity<String> stringResponseEntity = restTemplateUtil.sendPostHttpRequest2(urll, map);
        String body = stringResponseEntity.getBody();
        List<ResponseVO> responseVO = JSON.parseArray(body, ResponseVO.class);
        String path = "";
        String imageId = "";
        Map<String, Object> responseMap = new HashMap<>();
        if (responseVO != null || responseVO.size() > 0) {
            path = responseVO.get(0).getPath() + "/" + "result";
            //    String dateDir = new SimpleDateFormat("/yyyy/MM/dd").format(new Date());
            String savePath = localDir;
            path = path.replace("@", "%40");
            System.out.println("路径  " + path);
            String path2 = responseVO.get(0).getPath() + ".rjson";
            Map<String, Object> map2 = new HashMap<>();
            boolean flag = true;
            while (flag) {
                ResponseEntity<String> responseEntity = restTemplateUtil.sendHttpRequest3(path2, map2);
                String body1 = responseEntity.getBody();
                String[] split1 = body1.split("status");
                if (split1[1].contains("ERROR")) {
                    log.error("超图服务打印失败");
                    return RestResponse.fail("超图服务打印失败");
                }
                if (split1[1].contains("FINISHED")){
                    flag = false;
                    continue;
                }
                Thread.sleep(500);
            }
            restResponse = downloadsFile.downloadByUrl(path, savePath);
            imageId = restResponse.getData().toString();
            AttachmentInfoEntity attach = attachmentInfoService.getAttach(imageId);
            responseMap.put("attach", attach);
            responseMap.put("count", "断层分布图");
            responseMap.put("dataVersion", "活动断层数据版本为:" + sourceOfDangerBrVO.getDcDataVersion());
            responseMap.put("title", "");
        }
        File file = new File(localDir);
        File[] files = file.listFiles();
        for (File file1 : files) {
            if (file1.isFile()) {
                file1.delete();
            }
        }
        restResponse = RestResponse.succeed(responseMap);
        return restResponse;
    }

    @Override
    public RestResponse seismotectonics(SourceOfDangerBrVO sourceOfDangerBrVO) throws InterruptedException {
        //获取超图服务token
        String token = hypergraphService.getToken();
        if (PlatformObjectUtils.isEmpty(token)) {
            return RestResponse.fail("缺少超图服务token");
        }
        RestResponse restResponse = null;
        Properties configGroup = PropsHelper.loadProps("slw-config.properties");
        String url = configGroup.getProperty("supergraphRestTemplateUrl");
        List<District> list = sourceOfDangerBrVO.getList();
        List<String> codes = new ArrayList<>();
        String centerX = "";
        String centerY = "";
        String leftX = "";
        String leftY = "";
        String rightX = "";
        String rightY = "";
        int level = 0;
        if (StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getCenterX())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getCenterY())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getLeftX())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getLeftY())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getRightX())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getRightY())) {
            centerX = sourceOfDangerBrVO.getCircleVO().getCenterX();
            centerY = sourceOfDangerBrVO.getCircleVO().getCenterY();
            leftX = sourceOfDangerBrVO.getCircleVO().getLeftX();
            leftY = sourceOfDangerBrVO.getCircleVO().getLeftY();
            rightX = sourceOfDangerBrVO.getCircleVO().getRightX();
            rightY = sourceOfDangerBrVO.getCircleVO().getRightY();
            level = getLevel(Double.valueOf(leftX), Double.valueOf(leftY), Double.valueOf(rightX), Double.valueOf(rightY),null);
        } else {
            for (District district : list) {
                String district1 = null;
                //北京市，上海市，天津市，重庆市
                if ("北京市".equals(district.getProvince()) || "上海市".equals(district.getProvince()) || "天津市".equals(district.getProvince()) || "重庆市".equals(district.getProvince())) {
                    district1 = district.getCity() + "-" + district.getPrefecture();
                } else {
                    district1 = district.getProvince() + "-" + district.getCity() + "-" + district.getPrefecture();
                }
                String code = orgDivisionRepository.getCodeByTaskDistrict(district1);
                codes.add(code);
            }

//        List<String> strings = list.stream().map(District::getPrefecture).collect(Collectors.toList());
            String extent = districtBoundaryRepository.getExtent(codes);
            String center = districtBoundaryRepository.getcenter(codes);
            String[] split = extent.substring(4, extent.length() - 1).split(",");
            String[] s1 = split[0].split(" ");
            String[] s2 = split[1].split(" ");
            leftX = s1[0];
            leftY = s1[1];
            rightX = s2[0];
            rightY = s2[1];
            level = getLevel(Double.valueOf(leftX), Double.valueOf(leftY), Double.valueOf(rightX), Double.valueOf(rightY),null);
            String[] s = center.substring(6, center.length() - 1).split(" ");
            centerX = s[0];
            centerY = s[1];
        }
        //数据版本号：断层,断层岩性
        String dataVersion = sourceOfDangerBrVO.getDcDataVersion()+","+sourceOfDangerBrVO.getDcyxDataVersion();
        //获取图层图例
        TjVO tjVO=new TjVO("地震构造图",sourceOfDangerBrVO.getTjmb(),dataVersion,sourceOfDangerBrVO.getTjbt(),"0");
        Map<String,String> tempLayerUrlMap = getTempLayerUrlMapByTjVO(tjVO);
        List<Layer> layers = getLayer(tjVO.getTjlx(),tempLayerUrlMap);
        List<Layerr> layerrs = getLayerrs(tjVO.getTjlx(),tempLayerUrlMap,tjVO.getDataVersion());

        //获取Web打印出图模板列表
        List<TemplateEntity> templateEntityList = hypergraphService.getWebprintingLayoutsList();
        //根据参数设置请求体
        String jsonString = getRequestVOJsonStringByTjmb(sourceOfDangerBrVO.getTjmb(),templateEntityList,sourceOfDangerBrVO.getTjbt(),sourceOfDangerBrVO.getZtdw(),layerrs,layers,Double.valueOf(centerX),Double.valueOf(centerY),Double.valueOf(leftX),Double.valueOf(leftY),Double.valueOf(rightX),Double.valueOf(rightY),level,false);
        Map map = JSONObject.parseObject(jsonString, Map.class);

        String urll = url + "/webprinting/rest/webprinting/v1/jobs.json?token=" + token;
        ResponseEntity<String> stringResponseEntity = restTemplateUtil.sendPostHttpRequest2(urll, map);
        String body = stringResponseEntity.getBody();
        List<ResponseVO> responseVO = JSON.parseArray(body, ResponseVO.class);
        String path = "";
        String imageId = "";
        Map<String, Object> responseMap = new HashMap<>();
        if (responseVO != null || responseVO.size() > 0) {
            path = responseVO.get(0).getPath() + "/" + "result";
            //    String dateDir = new SimpleDateFormat("/yyyy/MM/dd").format(new Date());
            String savePath = localDir;

            path = path.replace("@", "%40");
            System.out.println("路径  " + path);
            String path2 = responseVO.get(0).getPath() + ".rjson";
            Map<String, Object> map2 = new HashMap<>();
            boolean flag = true;
            while (flag) {
                ResponseEntity<String> responseEntity = restTemplateUtil.sendHttpRequest3(path2, map2);
                String body1 = responseEntity.getBody();
                String[] split1 = body1.split("status");
                if (split1[1].contains("ERROR")) {
                    log.error("超图服务打印失败");
                    return RestResponse.fail("超图服务打印失败");
                }
                if (split1[1].contains("FINISHED")){
                    flag = false;
                    continue;
                }
                Thread.sleep(500);
            }
            restResponse = downloadsFile.downloadByUrl(path, savePath);
            if (restResponse.getCode() != 200) {
                return restResponse;
            }
            imageId = restResponse.getData().toString();
            AttachmentInfoEntity attach = attachmentInfoService.getAttach(imageId);
            responseMap.put("attach", attach);
            responseMap.put("count", "地震构造图");
            responseMap.put("dataVersion", "活动断层数据版本为:" + sourceOfDangerBrVO.getDcDataVersion() + "<br/>地层岩性数据版本为" + sourceOfDangerBrVO.getDcyxDataVersion());
            responseMap.put("title", "");
        }
        File file = new File(localDir);
        File[] files = file.listFiles();
        for (File file1 : files) {
            if (file1.isFile()) {
                file1.delete();
            }
        }
        restResponse = RestResponse.succeed(responseMap);
        return restResponse;
    }

    @Override
    public RestResponse historicalEarthquake(SourceOfDangerBrVO sourceOfDangerBrVO) throws InterruptedException {
        RestResponse restResponse = null;
        //获取超图服务token
        String token = hypergraphService.getToken();
        if (PlatformObjectUtils.isEmpty(token)) {
            return RestResponse.fail("缺少超图服务token");
        }
        Properties configGroup = PropsHelper.loadProps("slw-config.properties");
        String url = configGroup.getProperty("supergraphRestTemplateUrl");
        List<District> list = sourceOfDangerBrVO.getList();
        List<String> codes = new ArrayList<>();
        String centerX = "";
        String centerY = "";
        String leftX = "";
        String leftY = "";
        String rightX = "";
        String rightY = "";
        int level = 0;
        if (StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getCenterX())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getCenterY())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getLeftX())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getLeftY())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getRightX())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getRightY())) {
            centerX = sourceOfDangerBrVO.getCircleVO().getCenterX();
            centerY = sourceOfDangerBrVO.getCircleVO().getCenterY();
            leftX = sourceOfDangerBrVO.getCircleVO().getLeftX();
            leftY = sourceOfDangerBrVO.getCircleVO().getLeftY();
            rightX = sourceOfDangerBrVO.getCircleVO().getRightX();
            rightY = sourceOfDangerBrVO.getCircleVO().getRightY();
            level = getLevel(Double.valueOf(leftX), Double.valueOf(leftY), Double.valueOf(rightX), Double.valueOf(rightY),null);
        } else {
            for (District district : list) {
                String district1 = null;
                //北京市，上海市，天津市，重庆市
                if ("北京市".equals(district.getProvince()) || "上海市".equals(district.getProvince()) || "天津市".equals(district.getProvince()) || "重庆市".equals(district.getProvince())) {
                    district1 = district.getCity() + "-" + district.getPrefecture();
                } else {
                    district1 = district.getProvince() + "-" + district.getCity() + "-" + district.getPrefecture();
                }
                String code = orgDivisionRepository.getCodeByTaskDistrict(district1);
                codes.add(code);
            }

//        List<String> strings = list.stream().map(District::getPrefecture).collect(Collectors.toList());
            String extent = districtBoundaryRepository.getExtent(codes);
            String center = districtBoundaryRepository.getcenter(codes);
            String[] split = extent.substring(4, extent.length() - 1).split(",");
            String[] s1 = split[0].split(" ");
            String[] s2 = split[1].split(" ");
            leftX = s1[0];
            leftY = s1[1];
            rightX = s2[0];
            rightY = s2[1];
            level = getLevel(Double.valueOf(leftX), Double.valueOf(leftY), Double.valueOf(rightX), Double.valueOf(rightY),null);
            String[] s = center.substring(6, center.length() - 1).split(" ");
            centerX = s[0];
            centerY = s[1];
        }

        //获取图层图例
        TjVO tjVO=new TjVO("历史地震分布图",sourceOfDangerBrVO.getTjmb(),sourceOfDangerBrVO.getDcDataVersion(),sourceOfDangerBrVO.getTjbt(),"0");
        Map<String,String> tempLayerUrlMap = getTempLayerUrlMapByTjVO(tjVO);
        List<Layer> layers = getLayer(tjVO.getTjlx(),tempLayerUrlMap);
        List<Layerr> layerrs = getLayerrs(tjVO.getTjlx(),tempLayerUrlMap,tjVO.getDataVersion());

        //获取Web打印出图模板列表
        List<TemplateEntity> templateEntityList = hypergraphService.getWebprintingLayoutsList();
        //根据参数设置请求体
        String jsonString = getRequestVOJsonStringByTjmb(sourceOfDangerBrVO.getTjmb(),templateEntityList,sourceOfDangerBrVO.getTjbt(),sourceOfDangerBrVO.getZtdw(),layerrs,layers,Double.valueOf(centerX),Double.valueOf(centerY),Double.valueOf(leftX),Double.valueOf(leftY),Double.valueOf(rightX),Double.valueOf(rightY),level,false);
        Map map = JSONObject.parseObject(jsonString, Map.class);

        String urll = url + "/webprinting/rest/webprinting/v1/jobs.json?token=" + token;

        ResponseEntity<String> stringResponseEntity = restTemplateUtil.sendPostHttpRequest2(urll, map);
        String body = stringResponseEntity.getBody();
        List<ResponseVO> responseVO = JSON.parseArray(body, ResponseVO.class);
        String path = "";
        String imageId = "";
        Map<String, Object> responseMap = new HashMap<>();
        if (responseVO != null || responseVO.size() > 0) {
            path = responseVO.get(0).getPath() + "/" + "result";
            //    String dateDir = new SimpleDateFormat("/yyyy/MM/dd").format(new Date());
            String savePath = localDir;
            path = path.replace("@", "%40");
            System.out.println("路径  " + path);
            String path2 = responseVO.get(0).getPath() + ".rjson";
            Map<String, Object> map2 = new HashMap<>();
            boolean flag = true;
            while (flag) {
                ResponseEntity<String> responseEntity = restTemplateUtil.sendHttpRequest3(path2, map2);
                String body1 = responseEntity.getBody();
                String[] split1 = body1.split("status");
                if (split1[1].contains("ERROR")) {
                    log.error("超图服务打印失败");
                    return RestResponse.fail("超图服务打印失败");
                }
                if (split1[1].contains("FINISHED")){
                    flag = false;
                    continue;
                }
                Thread.sleep(500);
            }
            restResponse = downloadsFile.downloadByUrl(path, savePath);
            imageId = restResponse.getData().toString();
            AttachmentInfoEntity attach = attachmentInfoService.getAttach(imageId);
            responseMap.put("attach", attach);
            responseMap.put("count", "历史地震分布图");
            responseMap.put("dataVersion", "活动断层数据版本为" + sourceOfDangerBrVO.getDcDataVersion());
            responseMap.put("title", "");
        }
        File file = new File(localDir);
        File[] files = file.listFiles();
        for (File file1 : files) {
            if (file1.isFile()) {
                file1.delete();
            }
        }
        restResponse = RestResponse.succeed(responseMap);
        return restResponse;
    }

    @Override
    public RestResponse populationDistribution(SourceOfDangerBrVO sourceOfDangerBrVO) throws InterruptedException {
        RestResponse restResponse = null;
        //获取超图服务token
        String token = hypergraphService.getToken();
        if (PlatformObjectUtils.isEmpty(token)) {
            return RestResponse.fail("缺少超图服务token");
        }

        List<District> list = sourceOfDangerBrVO.getList();
        List<String> codes = new ArrayList<>();
        String centerX = "";
        String centerY = "";
        String leftX = "";
        String leftY = "";
        String rightX = "";
        String rightY = "";
        int level = 0;
        if (StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getCenterX())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getCenterY())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getLeftX())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getLeftY())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getRightX())
                && StringUtils.isNotBlank(sourceOfDangerBrVO.getCircleVO().getRightY())) {
            centerX = sourceOfDangerBrVO.getCircleVO().getCenterX();
            centerY = sourceOfDangerBrVO.getCircleVO().getCenterY();
            leftX = sourceOfDangerBrVO.getCircleVO().getLeftX();
            leftY = sourceOfDangerBrVO.getCircleVO().getLeftY();
            rightX = sourceOfDangerBrVO.getCircleVO().getRightX();
            rightY = sourceOfDangerBrVO.getCircleVO().getRightY();
            level = getLevel(Double.valueOf(leftX), Double.valueOf(leftY), Double.valueOf(rightX), Double.valueOf(rightY),null);
        } else {
            for (District district : list) {
                String district1 = null;
                //北京市，上海市，天津市，重庆市
                if ("北京市".equals(district.getProvince()) || "上海市".equals(district.getProvince()) || "天津市".equals(district.getProvince()) || "重庆市".equals(district.getProvince())) {
                    district1 = district.getCity() + "-" + district.getPrefecture();
                } else {
                    district1 = district.getProvince() + "-" + district.getCity() + "-" + district.getPrefecture();
                }
                String code = orgDivisionRepository.getCodeByTaskDistrict(district1);
                codes.add(code);
            }

//        List<String> strings = list.stream().map(District::getPrefecture).collect(Collectors.toList());
            String extent = districtBoundaryRepository.getExtent(codes);
            String center = districtBoundaryRepository.getcenter(codes);
            String[] split = extent.substring(4, extent.length() - 1).split(",");
            String[] s1 = split[0].split(" ");
            String[] s2 = split[1].split(" ");
            leftX = s1[0];
            leftY = s1[1];
            rightX = s2[0];
            rightY = s2[1];
            level = getLevel(Double.valueOf(leftX), Double.valueOf(leftY), Double.valueOf(rightX), Double.valueOf(rightY),null);
            String[] s = center.substring(6, center.length() - 1).split(" ");
            centerX = s[0];
            centerY = s[1];
        }

        //将数据设置进VO中
        Properties configGroup = PropsHelper.loadProps("slw-config.properties");
        String url = configGroup.getProperty("supergraphRestTemplateUrl");

        //获取图层图例
        TjVO tjVO=new TjVO("人口分布图",sourceOfDangerBrVO.getTjmb(),sourceOfDangerBrVO.getRkpcDataVersion(),sourceOfDangerBrVO.getTjbt(),"0");
        Map<String,String> tempLayerUrlMap = getTempLayerUrlMapByTjVO(tjVO);
        List<Layer> layers = getLayer(tjVO.getTjlx(),tempLayerUrlMap);
        List<Layerr> layerrs = getLayerrs(tjVO.getTjlx(),tempLayerUrlMap,tjVO.getDataVersion());

        //获取Web打印出图模板列表
        List<TemplateEntity> templateEntityList = hypergraphService.getWebprintingLayoutsList();
        //根据参数设置请求体
        String jsonString = getRequestVOJsonStringByTjmb(sourceOfDangerBrVO.getTjmb(),templateEntityList,sourceOfDangerBrVO.getTjbt(),sourceOfDangerBrVO.getZtdw(),layerrs,layers,Double.valueOf(centerX),Double.valueOf(centerY),Double.valueOf(leftX),Double.valueOf(leftY),Double.valueOf(rightX),Double.valueOf(rightY),level,false);
        Map map = JSONObject.parseObject(jsonString, Map.class);
        url = url + "/webprinting/rest/webprinting/v1/jobs.json?token=" + token;
        ResponseEntity<String> stringResponseEntity = restTemplateUtil.sendPostHttpRequest2(url, map);
        String body = stringResponseEntity.getBody();
        List<ResponseVO> responseVO = JSON.parseArray(body, ResponseVO.class);
        String path = "";
        String imageId = "";
        Map<String, Object> responseMap = new HashMap<>();
        if (responseVO != null || responseVO.size() > 0) {
            path = responseVO.get(0).getPath() + "/" + "result";
            //    String dateDir = new SimpleDateFormat("/yyyy/MM/dd").format(new Date());
            String savePath = localDir;
            path = path.replace("@", "%40");
            System.out.println("路径  " + path);
            String path2 = responseVO.get(0).getPath() + ".rjson";
            Map<String, Object> map2 = new HashMap<>();
            boolean flag = true;
            while (flag) {
                ResponseEntity<String> responseEntity = restTemplateUtil.sendHttpRequest3(path2, map2);
                String body1 = responseEntity.getBody();
                String[] split1 = body1.split("status");
                if (split1[1].contains("ERROR")) {
                    log.error("超图服务打印失败");
                    return RestResponse.fail("超图服务打印失败");
                }
                if (split1[1].contains("FINISHED")){
                    flag = false;
                    continue;
                }
                Thread.sleep(500);
            }
            restResponse = downloadsFile.downloadByUrl(path, savePath);
            imageId = restResponse.getData().toString();
            AttachmentInfoEntity attach = attachmentInfoService.getAttach(imageId);
            responseMap.put("attach", attach);
            responseMap.put("count", "人口分布图");
            responseMap.put("dataVersion", "人口普查数据数据版本为:" + sourceOfDangerBrVO.getRkpcDataVersion());
            responseMap.put("title", "");
        }
        File file = new File(localDir);
        File[] files = file.listFiles();
        for (File file1 : files) {
            if (file1.isFile()) {
                file1.delete();
            }
        }
        restResponse = RestResponse.succeed(responseMap);
        return restResponse;
    }

    @Override
    public RestResponse HumanCasualtiesAndPlacement(HumanCasualtiesVO humanCasualtiesVO) throws InterruptedException {
        List<AlgEntity> list = humanCasualtiesVO.getList();
        //保存计算结果
        List<EvaluationResults> resultslist = evaluationResultsService.getById(list.get(0).getResultAnalysis());
        if (resultslist.size() != 0) {
            evaluationResultsService.delete(list.get(0).getResultAnalysis());
        }
        EvaluationResults evaluationResults = new EvaluationResults();
        evaluationResults.setIaId(list.get(0).getIaId());
        evaluationResults.setId(list.get(0).getResultAnalysis());
        evaluationResults.setResult("2");
        evaluationResultsService.save(evaluationResults);

        //获取超图服务token
        String token = hypergraphService.getToken();
        if (PlatformObjectUtils.isEmpty(token)) {
            return RestResponse.fail("缺少超图服务token");
        }

        destoryAlgService.updateAlg(list);
        RestResponse restResponse = null;
        List<String> codes = new ArrayList<>();
        for (AlgEntity district : list) {
            String district1 = null;
            //北京市，上海市，天津市，重庆市
            if ("北京市".equals(district.getProvince()) || "上海市".equals(district.getProvince()) || "天津市".equals(district.getProvince()) || "重庆市".equals(district.getProvince())) {
                district1 = district.getCity() + "-" + district.getPrefecture();
            } else {
                district1 = district.getProvince() + "-" + district.getCity() + "-" + district.getPrefecture();
            }
            String code = orgDivisionRepository.getCodeByTaskDistrict(district1);
            codes.add(code);
        }

        String extent = districtBoundaryRepository.getExtent(codes);
        String center = districtBoundaryRepository.getcenter(codes);
        String[] split = extent.substring(4, extent.length() - 1).split(",");
        String[] s1 = split[0].split(" ");
        String[] s2 = split[1].split(" ");
        String leftX = s1[0];
        String leftY = s1[1];
        String rightX = s2[0];
        String rightY = s2[1];
        int level = getLevel(Double.valueOf(leftX), Double.valueOf(leftY), Double.valueOf(rightX), Double.valueOf(rightY),null);
        String[] s = center.substring(6, center.length() - 1).split(" ");
        String centerX = s[0];
        String centerY = s[1];
        Map<String, Object> bigMap = new HashMap<>();
        //将数据设置进VO中
        Properties configGroup = PropsHelper.loadProps("slw-config.properties");
        String url = configGroup.getProperty("supergraphRestTemplateUrl");

        //获取图层图例
        TjVO tjVO=new TjVO("人员伤亡分布图",humanCasualtiesVO.getRyswTemplate(),humanCasualtiesVO.getList().get(0).getResultAnalysis(),humanCasualtiesVO.getTjbt(),"0");
        Map<String,String> tempLayerUrlMap = getTempLayerUrlMapByTjVO(tjVO);
        List<Layer> layers = getLayer(tjVO.getTjlx(),tempLayerUrlMap);
        List<Layerr> layerrs = getLayerrs(tjVO.getTjlx(),tempLayerUrlMap,tjVO.getDataVersion());

        //获取Web打印出图模板列表
        List<TemplateEntity> templateEntityList = hypergraphService.getWebprintingLayoutsList();
        //根据参数设置请求体
        String jsonString = getRequestVOJsonStringByTjmb(humanCasualtiesVO.getRyswTemplate(),templateEntityList,humanCasualtiesVO.getTjbt(),humanCasualtiesVO.getZtdw(),layerrs,layers,Double.valueOf(centerX),Double.valueOf(centerY),Double.valueOf(leftX),Double.valueOf(leftY),Double.valueOf(rightX),Double.valueOf(rightY),level,false);
        Map map = JSONObject.parseObject(jsonString, Map.class);
        String urll = url + "/webprinting/rest/webprinting/v1/jobs.json?token=" + token;
        ResponseEntity<String> stringResponseEntity = restTemplateUtil.sendPostHttpRequest2(urll, map);
        String body = stringResponseEntity.getBody();
        List<ResponseVO> responseVO = JSON.parseArray(body, ResponseVO.class);
        String path = "";
        String imageId = "";

        Map<String, Object> responseMap = new HashMap<>();
        if (responseVO != null || responseVO.size() > 0) {
            path = responseVO.get(0).getPath() + "/" + "result";
            //    String dateDir = new SimpleDateFormat("/yyyy/MM/dd").format(new Date());
            String savePath = localDir;
            path = path.replace("@", "%40");
            System.out.println("路径  " + path);
            String path2 = responseVO.get(0).getPath() + ".rjson";
            Map<String, Object> map2 = new HashMap<>();
            boolean flag = true;
            while (flag) {
                ResponseEntity<String> responseEntity = restTemplateUtil.sendHttpRequest3(path2, map2);
                String body1 = responseEntity.getBody();
                String[] split1 = body1.split("status");
                if (split1[1].contains("ERROR")) {
                    log.error("超图服务打印失败");
                    return RestResponse.fail("超图服务打印失败");
                }
                if (split1[1].contains("FINISHED")){
                    flag = false;
                    continue;
                }
                Thread.sleep(500);
            }
            restResponse = downloadsFile.downloadByUrl(path, savePath);
            imageId = restResponse.getData().toString();
            AttachmentInfoEntity attach = attachmentInfoService.getAttach(imageId);
            responseMap.put("attach", attach);
            responseMap.put("count", "人员伤亡分布图");
            responseMap.put("title", "");
            //   responseMap.put("dataVersion","当前人口普查数据数据版本为:"+humanCasualtiesVO.getRkpcDataVersion());
            bigMap.put("rysw", responseMap);
        }
        File file = new File(localDir);
        File[] files = file.listFiles();
        for (File file1 : files) {
            if (file1.isFile()) {
                file1.delete();
            }
        }
        Map<String, Object> map1 = getMap(templateEntityList,leftX, leftY, rightX, rightY, centerX, centerY, level, humanCasualtiesVO);

        List<UrgencyVO> urgencyVOList = new ArrayList<>();

        for (AlgEntity algEntity : humanCasualtiesVO.getList()) {
            UrgencyVO urgencyVO = new UrgencyVO();
            urgencyVO.setProvince(algEntity.getProvince());
            urgencyVO.setCity(algEntity.getCity());
            urgencyVO.setPrefecture(algEntity.getPrefecture());
            if (algEntity.getResettleXz() == null) {
                urgencyVO.setResettleXz(algEntity.getResettle());
            } else {
                urgencyVO.setResettleXz(algEntity.getResettleXz());
            }

            urgencyVOList.add(urgencyVO);
        }

        bigMap.put("zzzhfx", map1);
        bigMap.put("list", urgencyVOList);
        restResponse = RestResponse.succeed(bigMap);
        return restResponse;
    }

    private Map<String, Object> getMap(List<TemplateEntity> templateEntityList,String leftX, String leftY, String rightX, String rightY, String centerX, String centerY, int level, HumanCasualtiesVO humanCasualtiesVO) {
        RestResponse restResponse = null;
        Properties configGroup = PropsHelper.loadProps("slw-config.properties");
        String url = configGroup.getProperty("supergraphRestTemplateUrl");

        //获取图层图例
        TjVO tjVO=new TjVO("地震灾害风险等级分布图",humanCasualtiesVO.getRyswTemplate(),humanCasualtiesVO.getList().get(0).getResultAnalysis(),humanCasualtiesVO.getTjbt(),"0");
        Map<String,String> tempLayerUrlMap = getTempLayerUrlMapByTjVO(tjVO);
        List<Layer> layers = getLayer(tjVO.getTjlx(),tempLayerUrlMap);
        List<Layerr> layerrs = getLayerrs(tjVO.getTjlx(),tempLayerUrlMap,tjVO.getDataVersion());

        //根据参数设置请求体
        String jsonString = getRequestVOJsonStringByTjmb(humanCasualtiesVO.getDzzhTemplate(),templateEntityList,humanCasualtiesVO.getTjbtt(),humanCasualtiesVO.getZtdw(),layerrs,layers,Double.valueOf(centerX),Double.valueOf(centerY),Double.valueOf(leftX),Double.valueOf(leftY),Double.valueOf(rightX),Double.valueOf(rightY),level,false);
        Map map = JSONObject.parseObject(jsonString, Map.class);
        //获取超图服务token
        String token = hypergraphService.getToken();
        if (PlatformObjectUtils.isEmpty(token)) {
            log.error("缺少超图服务token");
            throw new CustomException("缺少超图服务token");
        }
        String urll = url + "/webprinting/rest/webprinting/v1/jobs.json?token="+token;
        ResponseEntity<String> stringResponseEntity = restTemplateUtil.sendPostHttpRequest2(urll, map);
        String body = stringResponseEntity.getBody();
        List<ResponseVO> responseVO = JSON.parseArray(body, ResponseVO.class);
        String path = "";
        String imageId = "";

        Map<String, Object> responseMap = new HashMap<>();
        if (responseVO != null || responseVO.size() > 0) {
            path = responseVO.get(0).getPath() + "/" + "result";
            //    String dateDir = new SimpleDateFormat("/yyyy/MM/dd").format(new Date());
            String savePath = localDir;
            path = path.replace("@", "%40");
            System.out.println("路径  " + path);
            String path2 = responseVO.get(0).getPath() + ".rjson";
            Map<String, Object> map2 = new HashMap<>();
            boolean flag = true;
            while (flag) {
                ResponseEntity<String> responseEntity = restTemplateUtil.sendHttpRequest3(path2, map2);
                String body1 = responseEntity.getBody();
                String[] split1 = body1.split("status");
                if (split1[1].contains("ERROR")){
                    log.error("超图服务打印失败");
                    throw new CustomException("超图服务打印失败");
                }
                if (split1[1].contains("FINISHED")){
                    flag = false;
                    continue;
                }
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            restResponse = downloadsFile.downloadByUrl(path, savePath);
            imageId = restResponse.getData().toString();
            AttachmentInfoEntity attach = attachmentInfoService.getAttach(imageId);
            responseMap.put("attach", attach);
            responseMap.put("count", "地震灾害风险等级分布图");
            responseMap.put("title", "");
        }
        File file = new File(localDir);
        File[] files = file.listFiles();
        for (File file1 : files) {
            if (file1.isFile()) {
                file1.delete();
            }
        }


        return responseMap;
    }


    //椭圆--地震影响场
    /**
     * 定义地球半径（米）
     */
    //private final double R_EARTH = 6371000;
    private final double R_EARTH = 6378137;

    /**
     * 定义地球赤道周长（米）
     */
    private final double P_EARTH = 2 * Math.PI * R_EARTH;

    /**
     * 将Y轴的长度（米）转换成纬度
     *
     * @param length
     * @return
     */
    public double parseYLengthToDegree(double length) {
        //将length长度转换为度数
        double yDegree = length / P_EARTH * 360;
        return yDegree;
    }


    public Polygon createCircle(double x, double y, final double radius) {
        //将半径转换为度数
        double radiusDegree = parseYLengthToDegree(radius);
        //生成工厂类
        GeometricShapeFactory shapeFactory = new GeometricShapeFactory();
        //设置生成的类圆形边数
        shapeFactory.setNumPoints(64);
        //设置圆形中心点经纬度
        shapeFactory.setCentre(new Coordinate(x, y));
        //设置圆形直径
        shapeFactory.setSize(radiusDegree * 2);
        //使用工厂类生成圆形
        Polygon circle = shapeFactory.createCircle();
        return circle;
    }

    //获取图层图例（除文字标签）
    @Override
    public Layerr getLayerrByLayerNameUrl(String layerName,String layerUrl){
        //获取图层图例名称数组（除文字标签）
        List<String> strings = getLegendLayerNameList(layerName,layerUrl);
        Layerr layerr = new Layerr(layerUrl,strings);

        return layerr;
    }

    //获取图层图例名称数组（除文字标签）
    private List<String> getLegendLayerNameList(String layerName,String layerUrl){
        //如果没有文字标签，则返回空数组代表显示全部图例
        List<String> legendLayerNameList = new ArrayList<>();
        JSONArray jsonArray = getLayersRJson(layerUrl);
        boolean bool = false;
        for (int i = 0; i < jsonArray.size(); i++) {
            JSONArray layers = jsonArray.getJSONObject(i).getJSONObject("subLayers").getJSONArray("layers");
            for(int j=0;j<layers.size();j++){
                JSONObject layer = layers.getJSONObject(j);
                //获取图层过滤条件
                String name = layer.getString("name");
                name = name.replace("#",".");
                String legendLayerName = name + "@@" + layerName;
                String ugcLayerType = layer.getString("ugcLayerType");
                if (ugcLayerType.equals("THEME")) {
                    if("LABEL".equals(layer.getJSONObject("theme").getString("type"))){
                        //文字标签
                        bool = true;
                    }else{
                        legendLayerNameList.add(legendLayerName);
                    }
                }else{
                    legendLayerNameList.add(legendLayerName);
                }
            }
        }
        if(bool==false){//无文字标签显示全部图例
            legendLayerNameList = new ArrayList<>();
        }

        return legendLayerNameList;
    }

    //获取临时图层url
    private String getSqlTempLayer(String layerUrl, String sqlText,boolean showLabelBool) {
        String resultUrl = layerUrl;
        if (PlatformObjectUtils.isNotEmpty(sqlText)) {
            JSONArray jsonArray = getLayersRJson(layerUrl);
            for (int i = 0; i < jsonArray.size(); i++) {
                JSONArray layers = jsonArray.getJSONObject(i).getJSONObject("subLayers").getJSONArray("layers");
                for(int j=0;j<layers.size();j++){
                    JSONObject layer = layers.getJSONObject(j);
                    //获取图层过滤条件
                    String displayFilter = layer.getString("displayFilter");
                    if (PlatformObjectUtils.isNotEmpty(displayFilter)) {
                        displayFilter = "(" + displayFilter + ") AND " + sqlText;
                    }else{
                        displayFilter = sqlText;
                    }
                    layer.put("displayFilter",displayFilter);
                    if(showLabelBool==false && layer.getString("ugcLayerType")=="THEME"){
                        if(layer.getJSONObject("theme").getString("type")=="LABEL"){//文字标签子图层
                            layer.put("visible",showLabelBool);
                        }
                    }
                }
            }
            String jsonStr = JSON.toJSONString(jsonArray);
            JSONObject resultObj = postTempLayersSet(layerUrl,jsonStr);
            String newResourceID = resultObj.getString("newResourceID");
            String newResourceLocation = resultObj.getString("newResourceLocation");
            if (PlatformObjectUtils.isNotEmpty(newResourceLocation)) {
                resultUrl = newResourceLocation.replace(".rjson","");
            }
        }
        return resultUrl;
    }

    private JSONArray getLayersRJson(String layerUrl) {
        try {
            String dataUrl = layerUrl + "/layers.rjson";
            if(layerUrl.indexOf("tempLayersSet")!=-1){
                dataUrl = layerUrl + ".rjson";//临时图层
            }
            try {
                dataUrl = URLDecoder.decode(dataUrl, "utf-8");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
                return null;
            }
            dataUrl = dataUrl.replaceAll("%3A", ":").replaceAll("%2F", "/").replaceAll("\\+", "%20");
            //System.out.println(dataUrl);

            HttpHeaders headers = new HttpHeaders();
            headers.set("Content-Type", "application/json; charset=UTF-8");

            HttpEntity<JSONObject> entity = new HttpEntity<>(new JSONObject(), headers);
            ResponseEntity<String> exchange = restTemplate.exchange(dataUrl, HttpMethod.GET, entity, String.class);
            JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(exchange));
            JSONArray body = JSON.parseArray(jsonObject.getString("body"));
            if (body == null) {
                return null;
            }
            return body;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    private JSONObject postTempLayersSet(String layerUrl, String jsonStr){
        JSONObject result = new JSONObject();
        String dataUrl = layerUrl + "/tempLayersSet.rjson";
        try {
            dataUrl = URLDecoder.decode(dataUrl, "utf-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            return null;
        }
        dataUrl = dataUrl.replaceAll("%3A", ":").replaceAll("%2F", "/").replaceAll("\\+", "%20");

        HttpHeaders headers = new HttpHeaders();
        headers.set("Content-Type", "application/json; charset=UTF-8");

        HttpEntity<String> entity = new HttpEntity<>(jsonStr, headers);
        ResponseEntity<String> exchange = restTemplate.exchange(dataUrl, HttpMethod.POST, entity, String.class);
        JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(exchange));
        JSONObject body = JSON.parseObject(jsonObject.getString("body"));
        if (body == null) {
            return null;
        }
        result = body;

        return result;
    }

    //根据图件模板等信息设置打印出图请求体
    @Override
    public String getRequestVOJsonStringByTjmb(String tjmb,List<TemplateEntity> templateEntityList,String tjbt,String ztdw,List<Layerr> layerrs,List<Layer> layers,
                                               Double centerX,Double centerY,Double leftX,Double leftY,Double rightX,Double rightY,int level,boolean baseLayerBool){
        //获取模板文件名
        String templateName = null;
        List<CustomItem> customItems = new ArrayList<>();
        if(PlatformObjectUtils.isNotEmpty(tjmb)){//图件模板id
            MapViewVO view = mapManagerService.view(tjmb);
            //根据模板名、模板信息列表获取模板信息
            TemplateEntity templateEntity = getTemplateEntityByTemplateName(view.getTemplateName(),templateEntityList);
            if(templateEntity!=null){
                //根据经纬度范围获取level值
                level = getLevel(leftX, leftY, rightX, rightY,templateEntity);
                templateName = templateEntity.getTemplateName();
            }
            if(view.getType().equals("1")){//地震构造图模板
                //自定义图例--1970年前地震
                CustomItem customItem0 = new CustomItem("1970年前地震","iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAIAAACRuyQOAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAwSURBVEhL7c1BDQAwEASh+je9FUFyr8EAb1eaRJNoEk2iSTSJJtEkmkSTaBJX0/YBgKZNeNPFzR8AAAAASUVORK5CYII=");
                CustomItem customItem1 = new CustomItem("8.0≤M<9.0","iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAALjSURBVFhHzZc9TCJBFMeHE81KUDd+RC4m3tptYbGFxVYGK7lGt6Qw5BoT7Oi42BgbjRU5Y8J1NiZnR66ihO5K6KCDDqygMEHjx7t54wN3j10+nRy/lw3Mwr75z5vZeW98wGETwif6nAgmSszY01QsFlmz2WSKojDTNOnuiKCYYSgUCpA4OgJteRkHAcbCAoRVFUx+YTs0Pw/xWAyy2Sw9MTgDi0EREdMUnad4pxV+uVmN30/zK8LFGRsbkMvlyEN/BhKTOjsTIrIeAryswP+PUYtHo+SpNz3FtFot+La3Bwkeensnw1p6dhbChgGNRoM8u9NTTHR3F64DgY7TcQyjGt7cFAP0wlPM+fExfOdTY3c4rv2anhYD9MJVDC5WXCN2Rx9l8bk5SF9eUk9OXMXgWzPsYh3U8G3TFhddp6trB87n8+yhXGZfJWWsz9yv9fjIfl5d0R0bJKoDbli4T8i0P9y/qevU4ztdYnAHxVDKNi0YhEqlQr2+4ZimarXKlNdXEUrZGFNTIq/ZcYip1+ss5PdTSy7qy4tIsHYcYvBHlb7L5sv9vZgJOw4xWAY80HfZ3AUCLBQKUesNhxhN01j1+Zlacmny5aCqznlwiEGlTS6m5aMbEin7fEzXdWoR9FZ1sHZ2ICP51cZaCIuzf3FEBtmPxdjvYJBacrjlUxQ9OKCWDRLVAXMG5g5ZG18Lo4Iba61GPb7jmigzmQxYkrJ2yu+HxOEh9eTEVQxibW9DhtcfdkfjWolHxVhf9yywPMVgiWjyghodfIQ1UMjKSlc+suMpBsEHjbU1yI0pCAdkrq6Koq0XPcUgGKHI1hacKIoY3TCGixXXiIhwqUQevekrBsE5PkkmQV9agnPu3OvM1Lb22UnnxxRcrP1OBW2GOt5iVv9xccFub26Y+vTEDJ55MeG1wXxTnJlhVV6GWJbFkqenIsUMyshnbaxF8LJnXkwnhmGMfOYeWYwMutLB/2SCxDD2F7KDJ3fd629pAAAAAElFTkSuQmCC");
                CustomItem customItem2 = new CustomItem("7.0≤M<8.0","iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAJ6SURBVFhH7Zg9SCNBFMfHI+oGP7J+gFuFFUS2nDI24lVedys2KUUQLAM2dimvFGwsAzaHIuxZXazsTJlctaXb7XYJgsRCfDdvd1bCZXZ2slmOFPk9hs3bZF7+uztv3ktmgEEmhC/8OBFMxSQxFZNE5mzq9Xqk0+mQIAjCQSkluq6Hx8ygmFFoNBqwRyno8/Owp+tQXV6GGn9NSyUw19ehdnICvu/zGeooi2m320A3N+FocREe2TUk2TN776JQAJOJrJ+d8dlqKIn5eX0NlbU1aEtE/Gt99tk6E27v7kK/3+eR5KSKcW5v4Rt7BBg8izmzs2Dv7CgJkopxXRfo6mpmIbFdFYtwWq3yqMlIxeAaGeXRyMxmi9txHB5ZTKIYXCfVlZXPYOMaXhRenIxEMZi+sqzJYpj6mJVJCHfgcENzXfI15+bi++sr+XV3x71hhGJwZ6XFIvfyg76/kz9PT9wbRijG8zxisol5Y7AR+H7kCPivhVJno/fyEjkChGIMwyBBocC9/PDYMMvlyBEgFGOaJvE+PriXH6GY7e3IESAUY1kWeZubI88z/EROPJRKZP/ggHsCeIoPgW0AVt/BfWIcw5Kia5q0RiWKwX4E24Bx61JsWMHTWgppbbq6vITTpaXPgFkNexzLMFIrt1QMgv0ItgGDwUexLhMS9kKSMhCTKqbb7ULFsuCCtQGDX6JiLgrZ2IDf9/c8mpxUMTG142OosCarpbCG8G6cLywALZfDnkgVZTFIq9UK7xJW33OWaVjVB0eDDWzQDbbOftTryu1mTKafKlhIm80mebi54WcizK0tsn94SGzbJpqm8bPqTP+FSGIqJokJEkPIX6kKUx/XEzbxAAAAAElFTkSuQmCC");
                CustomItem customItem3 = new CustomItem("6.0≤M<7.0","iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAJFSURBVFhH7Zc9SCtBEMdXSSD4maiB2JlC3PLEZkuttJJYCAEbX6dWvk5sLK8UbAQbwUbLdClTJt2lS6ySLmVSGUVh3sy+eSKY3du7pPDB/YYlu8fd7D+zczt7U4CIH8I0//4IEjEmEjEm/n8xjUZD/D47Ezubm6KYz4vczIzu/zo8FJVKhe+KAe0zrvR6PdhTClQ2C9f4aA1bB1uf+/fYSouLoKSEVqvFT7njLOb+7g7k8jJUccIwq+M93tIS+FdX/LQbTmL8y0soLyzoCLjaEO+9mJ3VkXQlVEwQBKAwIuQ8jp3Mz8PtzQ17s2MVMxwOQa2vQxBTCBn9CYk51ul02KsZqxhacwr1V+dxjPLMZbmsYtZWVvTbMglbm5sLjY5xn2k2myL7/i6KEzpglNBX2B5kFNNut4XEyE2Kjbc38Rxg9lkwihkMBiL78cGj8clge315+TswYBSTyWTE63SsahEb42xSStFOpXg0Ps/oa2Nri0cGOJG/QXtMATesKLuuzaie1et19j4a6zKV9vfFUzrNV+LTmsIcxMqulOIrBljUSKhKe4UC9MaMzjZGpVarsVczVjHE48MDlHO5T8dR7TadhpOjI/ZmJ1QMUd7dhetU6nMCV6MyIFdXdf654CSGnB0fHMAehttlySjpj/GQRfWIltoVJzH/qFarIPN5uMAojarkVMfoBEiHMDqMRSWSGKLf74Pv++AVddXSBdDDKOg+Ftbz09NI0fjK2N/a3W5Xlw7P8/hKfJIPfxOJGBOJmNEI8Qdh/Q4riasTxwAAAABJRU5ErkJggg==");
                CustomItem customItem4 = new CustomItem("5.0≤M<6.0","iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAHySURBVFhH7Zc/SAJRGMC/4qJTy/4RiIO0dZtCy0OJGhuvLWhpbHFqcbuxsbExcBFapEl0yaYzcLiGoJakSTdxkHMQvt47viSCO7/n5HC/j4f34P35cc/3fbqCElgSVulzKYhlwohlwohlwlgqmYWTXrvdDtprswmTyQQy2Szkj4/Btm2wLItGaaJkdOj3+3gmBJ5ub6Mjpzdke5atJlvFMNBKp7FSLqPv+zSDj5ZM4+kJrb29QCAqbk0TC7kc9no9msmDLaPeiBIZzhH5DVeOE5ZFs3mwZdTRzHsj/6OSSuGt49AK82HJ1Ot1tLe2Zptww5fyGSk0HA5ppWhYV/ul1YKT0Yh6fBLyngrDCG4dB5aM57pQoGdd8uMxeN0u9aJhyXx8fcGCmQMOplP4/vykXjQsGXF0BB161uVtfR3ypRL1omHJ5ItF8OTZL4KXSEChwDxk+iJH4rouCplx/94UTvTl8tb+Pvs2sfPM9eUl3q+tzTbixMXODtaqVVphPmwZVWtUileZlRN3sk5dnZ/TbB5sGYWqNSrFOxsbs03/hyoX9u5uIKJbLLVkfnFubjCTTOIZVe4H2VTFVpU8s7mJ9cdHGqnHwr9nBoMBeJ4HnU4Hvt/f4VBefyFE0EzTpFF6xP8ow4hlwohlwohlwlgiGYAfIj2oa5/vU+IAAAAASUVORK5CYII=");
                CustomItem customItem5 = new CustomItem("4.7≤M<5.0","iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAGqSURBVFhH7Ze/a8JAFIBfiyH1B3ooSCbpmK0Bh6ZT49ZJOgouLoKj/0UHBycRXPwX3JwEO2kn00nH4hIXSSfrILze2UOk9Mhdujjc9wj64sX7TN69wyukwIVwzV8vAi0jQsuI0DIitIyIf3Xg6XQKvu8DIQRc1wXbtvknMWEyqgwHAyTJJHqEYNs0sZHJoJ3NomvbuFwu+Sh1lGWeKxVs5HIY0t/xO2b0nJPP47DX46PVUJLpdjrYTqdPk/8VX1wozh2SlgmCAG/po2CTRQW7Q+yRqSK9mkajETwdDpCUKPcHOuZjvYbNZsPPyCEt8zaZwP1ux7NoXMOA+XzOMzmkZT63WyD8vQw3tAT2+z3P5JCWeaxW4dU0eRaNTw/HcX4SWXjtRLJYLNChS/q8UEUR0K+1aLGrorS0W/U69g3jNKkonmgzHI/H/Cp5lGTCMESnVMJuInGa+DxYI2QNsVWr8SvUUJJhMKF2s3ls/61UCvtU4IUeNZrbhcJxq4hL7I1ytVodN8r32QxIsQh35TJ4ngeWZfER6uj/TSK0jAgtI0LLiNAyIi5IBuAb3BXobyA1Dz8AAAAASUVORK5CYII=");
                //自定义图例--1970年以来地震
                CustomItem customItem00 = new CustomItem("1970年以来地震","iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAIAAACRuyQOAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAwSURBVEhL7c1BDQAwEASh+je9FUFyr8EAb1eaRJNoEk2iSTSJJtEkmkSTaBJX0/YBgKZNeNPFzR8AAAAASUVORK5CYII=");
                CustomItem customItem01 = new CustomItem("8.0≤M<9.0","iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAIAAACRuyQOAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJxSURBVEhL7VYrTMNQFH1iS8YY7QufQEJCNjeBqEBUkaGYIpNTywzJcHUQTB0IxBJM5eRk5eTk5OTk5OTk5Di0F/J6X1e6FhCEkyP2efec97n3vifWv4V/J2A6nY7H48lkQt9TI5UT1J27u+rhoRDCMs2GlLaU+HxiGL1OZzQa0bhEfOEEj6ZtQ70vxFyIdZQLITwhmlJatRoWSjEbkOTUf3qCx0gz0DkVAgvttdsUGYd4p9Vq1b25cQyDKSbT29lpWNZyuSSVKOKd2tfXg3KZCaUhNqBxfo6JkpCCGKfnx8cH02QS6TksFjFR0lLAnZACOBsWvC17e3ve6yspfoA7IdPSpEAykZPV/X22hxEnZCpSiIVlo7O72395Id0AESeUIeqDxWTjRAi7XifdABEn1DwWzmIys1qpzOdzklad8Cv+Y6PzsGWavu+TuuqEpoluxkbnYbdSGQwGpK46oVGig7HReeiCrkvqqtM3Jl7IXrnseR6p/+g5tQ1jOBySuuqEQpOl0koLyEz0GnQcUledgNbVla8FZCMuM9ycpBsg4oRUQcKwmGx8LhQeHId0A0ScsIHoV/mLF0dQRRNYLEg3QMQJQK2h4ljktuwXCs7tLSl+gDsBrctLv1hkwek5Qy6cnemXYYwTrme7VkMAk0jDJWyOjtR294kYJwBDrdPTsSaUTEzOPj5WM1tFvBOAlTUvLtxSCdNkijqRAjib952YzShew0YnAHvt3t/XDw6QsvpjL2T45KtLiRTY9CoKkeQUAsmKykAZouZRbe99MyDaGnp/+IyNPRiGr50+gQNAaaM9h0D33Op1voVTTvw9p/X6DaQpWHxb2dSKAAAAAElFTkSuQmCC");
                CustomItem customItem02 = new CustomItem("7.0≤M<8.0","iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAIAAACRuyQOAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIdSURBVEhL7ZYtbMJQFIWvKGEEKN1YAplYNldZWQzZHBIxgSKEZAmSBEMyUYlsMoMkmSGZaaYqkUgkchKJRLKT9YWUy3vta1hmtpMjmsA9X//uvaX9b+mfdI7+OGm73S4Wi/l87vs+DlarlfhBT1qk2Wz24DhWPv9gWR3THH4fOJXK3fX18Pl5s9mI/yUqhYQTd+7ve6XSgmh/4k8i3zDuTNMbjUSBWkmk+dubW62uTgDMOyKvVGo3m7vdTlTKpCQF7+8ty0IKy1U5yOXajUYCTE5ar9fO1ZU+JvK0UBh0OiLiRHISnk3qTZO6XakEQSBSjiUh4fF0Li9ZhKZxfjhLEXQsCQkvtPRN0zTefmmrcRLaE33DijPZMwzv5UXExcRJaH50JSvO5ABP6/FRxMXESRgH6FNWnMlLIte2RVxMP09aE9k3NyIuJk4KwxANy4ozOSRqua6Ii4mT0LO2abLiTJ4SDbpdERcTJ0GY0BidrF7fquaVkLAIMKFZvaYxwKyLC+n0k5Cwb7AIsg69yBjqqg0iIUHT19dBucxSUo17btfrqnEuJ0HYN1gELCvBW7QRlpl65StJGEtoQL9QYIlSo4fcWi38+BDFMilJkYb9vmtZaHsWfTAuZVwsOre3aA9Ro1AKCVoul7g4TOixYWDGHzwjwtdLvVyeeF7yXo+UToqEBzCZTLBQDu49PeGLTIcRSZd0vv5J5+i3SPv9F7HKyDwIb+JFAAAAAElFTkSuQmCC");
                CustomItem customItem03 = new CustomItem("6.0≤M<7.0","iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAIAAACRuyQOAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAICSURBVEhL7ZYhbMJAFIZPsJANSm8UEkANsaSysnJuyJEgSEgIEhxywUxWNplpgmkyg0QikUgkEllZiWT/tpdlvV6vx0gmFr78ogTe//de715hx7/iknQOl6Rz0E3abDbTyeTBce5qNX59jYtRr7dcLulrDfKToijquK7Luc/YmrE9Y/HnRcjYk2m6tr3b7einSnKSwvnctqwVY8cMbRhzqlXv5YUKslElebNZv1LBCgR3QQfGnkslrJvKMshM2m63rmXBRfDN0tgwgtdXKpYhTzocDu79/TZlpxDuyeZ8v9+TRQp5EvqOhgheucLjVPRQnoStjD0mGOnorlzOWpYkCU/IMU3BQlPTYtH3fTJKIklaLBbYcoKFpgJsjeGQjJJIkoIgGN/cCBaawnHG7CCjJJKkMAxH5bJgoanTkjDiMHsEC009Fwqe55FREkkSDlPDMHJHg1S4RdwoGSWRJIHxYBBcXQkuudrh8LZaZJFCnoT57TQaUcpLrQfO1+s1WaSQJ4HF21v/9lbwUgg9QCeoWEZmEug/PvqFguAoFeaQ3WziAVOlDFUSKkfdbodzRRuxcUamiXGHhlNZBqqkL1arlV2vY/sKox2DEW9hvCfxtqSfKslPAnEc45Q47Tb7nKGYih8XtRr+WeQu5RutpJ9gVGME04dTODnp11ySzuH/JR2P78gxanSsMirsAAAAAElFTkSuQmCC");
                CustomItem customItem04 = new CustomItem("5.0≤M<6.0","iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAIAAACRuyQOAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGkSURBVEhL7ZUhb8JAGIZPlEAolAIhqUJXIiuHIyhIECQY5BAkJBgSxMnKysklGBJMg6qs7E9AIisrK7t34wRp767dmkxsffK63vc97eX6HUl+i8pUhspUhn9u8n2fUjqxrJfRaDmd2rZ9u93YswIUMoVh+CnQdUqIR4hPyJmQg6KYmnbYbuM4Zuuk5Ju869Xs9yFIeLEbjdFweL/f2WoxOSZ8DTRRRvCcgBDLNFmBmBwTNk30Nc85qKpNKasRIDO5rjvrdFJNuYkJMVQ1iiJWyUNm2m02TqapKHgnvBmr5CEz4TTjmKU6ikIVhR6PrJKHzGRoWpjpKMo7IevFglXykJlm47Gb6SjKrl53HIdV8pCZsBvYk1RHUfBfY4iwSh4yUxAElq6nOnKDTTYHg5+fPfC6Wr3Vaqm+2Sy73fPpxGoE5Jgw0zBsMAVSrZ/jKMp6PmcFYnJMADMNw4a2WikBgik16/WgKTJk800P6H5vNJuTr3GOA41BjiNgtNvu5cJW5FHUBDBtPc/DFYX/BpcTTlrB++LBN0wlqUxlqExl+HumJPkAVpaCe+f7qwcAAAAASUVORK5CYII=");
                CustomItem customItem05 = new CustomItem("4.7≤M<5.0","iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAIAAACRuyQOAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAFbSURBVEhL7ZQhb4NAFMdPtGlKmzvSmqlmEomcXN1kRQVJkwbTBImo2DeYqEA1JDUnkUgkchLJR0AiJ9lbdyHkGnhHLqm6X/6KvHu/0nsP0jwLY9LBmHQwJh3GmfI8j6KIc16WpXikjKqJ3272fP5u2+Fs5i+XDqVvjjPKp2Tabbc+YzUhTSffhLirFb9eRREGbooul3Cx6Dra/Nxlim+GmKqqeqUUOkqONvBm8DeK6kEQUxzHgWVJ3aW8WBb8IHGgH8Tk7/f8obWUHWNpmooD/SAmmIX0obUUj9IkScSBfhATbA+MtdRaCky8ylAgpqIoXMak1t1UcE+UiupBEBMQHA7xdCoJ2nzYdpZlonQQ3FTXtbvZRJOJ5IBFhnUOPE/UYeAmAGTh6QT3ARMfE/J1nwJnvYZPlKhQQMn0D1z733odj5/nMwybyg51GWHSxJh0MCYdjEmHZ5ma5hcYDyWu0lii8wAAAABJRU5ErkJggg==");
                customItems = Arrays.asList(customItem0,customItem1,customItem2,customItem3,customItem4,customItem5,customItem00,customItem01,customItem02,customItem03,customItem04,customItem05);
            }
        }
        //根据参数设置请求体
        String jsonString = getRequestVOJsonString(templateName,tjbt,ztdw,layerrs,layers,centerX,centerY,leftX,leftY,rightX,rightY,level,baseLayerBool,customItems);

        return jsonString;
    }

    //设置打印出图请求体
    @Override
    public String getRequestVOJsonString(String templateName,String tjbt,String ztdw,List<Layerr> layerrs,List<Layer> layers,
                                   Double centerX,Double centerY,Double leftX,Double leftY,Double rightX,Double rightY,int level,boolean baseLayerBool,List<CustomItem> customItems) {
        RequestVO requestVO = new RequestVO();
        LayoutOptions layoutOptions = new LayoutOptions();
        if(PlatformObjectUtils.isEmpty(templateName)){
            templateName = "Administrative_Active_Fault-hf1012";//默认模板横版不带简介
        }
        layoutOptions.setTemplateName(templateName);
        String title = tjbt;
        //用URLEncode编码，防止如%符号不能打印
        title = setStringEncoder(title);
        layoutOptions.setTitle(title);//标题
        //用URLEncode编码，防止如%符号不能打印
        ztdw = setStringEncoder(ztdw);
        layoutOptions.setAuthor("制图单位："+ztdw);//制图单位
        String date = DateUtil.format(new Date(), "yyyy年MM月dd日");
        layoutOptions.setTime("制图时间:"+date);//制图时间
        ScaleBarOptions scaleBarOptions = new ScaleBarOptions("","BAR",5,"METER");
        layoutOptions.setScaleBarOptions(scaleBarOptions);
//        NorthArrowOptions northArrowOptions = new NorthArrowOptions("file://NorthArrow.svg");
        NorthArrowOptions northArrowOptions = new NorthArrowOptions("file://ARROW_RIGHT_FILL_WITH_COLOR.svg");
        layoutOptions.setNorthArrowOptions(northArrowOptions);
        //获取经纬网参数
//        MapGridOptions mapGridOptions = getMapGridOptions(leftX, leftY, rightX, rightY);
        //根据level获取经纬网参数
        MapGridOptions mapGridOptions = getMapGridOptionsByLevel(level);
        layoutOptions.setMapGridOptions(mapGridOptions);
        LegendOption legendOption = new LegendOption();
        legendOption.setTitle("图 例");
        legendOption.setLayers(layerrs);
        //自定义图例
        legendOption.setCustomItems(customItems);
        layoutOptions.setLegendOptions(legendOption);
        requestVO.setLayoutOptions(layoutOptions);
        ExportOptions exportOptions = new ExportOptions("png", 120.0);//dpi取值推荐：72,120,200,254,300
        if(baseLayerBool){//天地图街道图作为底图
            exportOptions = new ExportOptions("png", 96.0);//dpi取值推荐：96
        }
        requestVO.setExportOptions(exportOptions);
        Content content = new Content();
        content.setType("WEBMAP");
        com.css.fxfzaqbz.modules.supergraph.entity.Value value = new com.css.fxfzaqbz.modules.supergraph.entity.Value();
        leftAndright leftBottom = new leftAndright(leftX, leftY);
        leftAndright rightTop = new leftAndright(rightX, rightY);
        Extent extent = new Extent(leftBottom, rightTop);
        value.setExtent(extent);
        value.setMaxScale("1:2130.3378410848");
        value.setLevel(level);
        //value.setLevel(15);
        leftAndright center = new leftAndright(centerX, centerY);
        value.setCenter(center);
        if(baseLayerBool){//天地图街道图作为底图
            String tk = "ad0a520abd480f45a173115c2a80f723";//天地图浏览器端token
            BaseLayer baseLayer = new BaseLayer("TIANDITU_VEC_4326", true,true,tk, "天地图矢量(经纬度)");
            value.setBaseLayer(baseLayer);
        }
        value.setLayers(layers);
        value.setDescription("");
        value.setProjection("EPSG:4490");
        value.setMinScale("1:591658710.909131");
        value.setTitle("China");
        value.setVersion("2.3.0");
        content.setValue(value);
        requestVO.setContent(content);
        JSONObject requestJsonVo = (JSONObject) JSONObject.toJSON(requestVO);
        String jsonString = JSONObject.toJSONString(requestJsonVo);
        System.out.println("打印请求体----"+jsonString);

        return jsonString;
    }

    //用URLEncode编码，防止如%符号不能打印
    public String setStringEncoder(String string) {
        String stringEncoder = string;
        try{
            stringEncoder = URLEncoder.encode(string,"UTF-8");
        }catch (Exception e){
            e.printStackTrace();
        }

        return stringEncoder;
    }

    //重点场所风险评估一键出图生成应急疏散辅助决策图
    @Override
    public RestResponse assessEmphasisNetworkPath(AssessEmphasisVo assessEmphasisVo) throws InterruptedException {
        //获取超图服务token
        String token = hypergraphService.getToken();
        if (PlatformObjectUtils.isEmpty(token)) {
            return RestResponse.fail("缺少超图服务token");
        }
        RestResponse restResponse = null;
        //出图范围 km为单位
        Double ctfw = assessEmphasisVo.getCtfw();
        //制图单位
        String ztdw = assessEmphasisVo.getZtdw();
        //重点目标
        String zdmb = assessEmphasisVo.getZdmb();
        //标题
        String tjbt = assessEmphasisVo.getTjbt();//地震应急疏散辅助决策图

        //根据重点目标名称查询Site对象
        Site site = supergraphRepository.getSiteByName(zdmb);
        Double centerX = site.getSsLongitude();
        Double centerY = site.getSsLatitude();
        HashMap<String, Double> hashMap = getPeopleNearby(BigDecimal.valueOf(centerX), BigDecimal.valueOf(centerY), ctfw);
        Double leftX = hashMap.get("minlng");
        Double leftY = hashMap.get("minlat");
        Double rightX = hashMap.get("maxlng");
        Double rightY = hashMap.get("maxlat");
        int level = getLevel(leftX, leftY, rightX, rightY,null);
        //将数据设置进VO中
        Properties configGroup = PropsHelper.loadProps("slw-config.properties");
        String url = configGroup.getProperty("supergraphRestTemplateUrl");
        //根据版本号查询交通网络分析服务版本信息
        NetworkanalystVersion networkanalystVersion = hypergraphService.getNetworkVersionByVersion(assessEmphasisVo.getNetwork().getDataVersion());//道路网络数据集版本
        String networkId = networkanalystVersion.getId();
        //获取出图范围内的应急避难场所
        List<JcEmergcyShelterVo> jcEmergcyShelterVos = new ArrayList<>();
        String geom = "POLYGON((" + leftX + " " + leftY + "," + rightX + " " + leftY + "," + rightX + " " + rightY + "," + leftX + " " + rightY + "," + leftX + " " + leftY + "))";
        String urlu = configGroup.getProperty("restTemplateUrl") + "/datacenter/jcEmergcyShelter/findByGeom" +
                "?dataVersion="+assessEmphasisVo.getYjbncs().getDataVersion()+"&geom="+geom+"&code="+assessEmphasisVo.getYjbncs().getNum();
        JSONObject valueMap = new JSONObject();
        JSONArray jsonArray = (JSONArray) hypergraphService.getJCSJ(urlu, 3, valueMap).getData();
        if(jsonArray!=null && jsonArray.size()>0){
            for(int i=0;i<jsonArray.size();i++){
                JSONObject obj = jsonArray.getJSONObject(i);
                JcEmergcyShelterVo jcEmergcyShelterVo = new JcEmergcyShelterVo();
                jcEmergcyShelterVo.setBncsmc(obj.getString("bncsmc"));
                jcEmergcyShelterVo.setJesLongitude(obj.getDouble("jesLongitude"));
                jcEmergcyShelterVo.setJesLatitude(obj.getDouble("jesLatitude"));
                jcEmergcyShelterVos.add(jcEmergcyShelterVo);
            }
            //根据重点目标、出图范围和应急避难场所列表获取交通网络分析服务的最佳路径分析
            hypergraphService.getNetworkanalystPathList(networkId, site, ctfw, jcEmergcyShelterVos);
        }

        //图例
        List<Layerr> layerrs = new ArrayList<>();
        //图层
        List<Layer> layers = new ArrayList<>();
//        //中国行政区划图
//        Layerr layerr15 = getLayerrByLayerNameUrl("中国行政区划图",url + "/map-datacenter/rest/maps/中国行政区划图");
//        layerrs.add(layerr15);
//        String url15 = url + "/map-datacenter/rest/maps/中国行政区划图";
//        Layer layer15 = new Layer("TILE","中国行政区划图", url15);
//        layers.add(layer15);
        //基础地理数据
        String jsdlsjDataVersion = assessEmphasisVo.getJcdlsj().getDataVersion();
        if (PlatformObjectUtils.isNotEmpty(jsdlsjDataVersion)) {
            List<String> list = hypergraphService.getRestMapUrlList(jsdlsjDataVersion);
            if(list.size()>0){
                for(String mapUrl : list){
                    List<String> strings = new ArrayList<>();
                    Layerr layerr = new Layerr(mapUrl,strings);
                    layerrs.add(layerr);
                    String name = mapUrl.substring(mapUrl.lastIndexOf("/")+1);
                    Layer jsdlsjLayer = new Layer("TILE",name, mapUrl);
                    layers.add(jsdlsjLayer);
                }
            }
        }
        //道路
        String dlDataVersion = assessEmphasisVo.getDl().getDataVersion();
        if (PlatformObjectUtils.isNotEmpty(dlDataVersion)) {
            String dlUrl = url + "/map-datacenter/rest/maps/jc_lrdl@datacenter";
            String sql = "data_version='"+dlDataVersion+"' and del_flag='0'";
            dlUrl = getSqlTempLayer(dlUrl, sql,true);//获取临时图层
            System.out.println("临时图层----"+dlUrl);
            //图例
            Layerr layerr = getLayerrByLayerNameUrl("jc_lrdl@datacenter", dlUrl);
            layerrs.add(layerr);
            Layer dlLayer = new Layer("TILE","jc_lrdl@datacenter", dlUrl);
            layers.add(dlLayer);
        }
        //铁路
        String tlDataVersion = assessEmphasisVo.getTl().getDataVersion();
        if (PlatformObjectUtils.isNotEmpty(tlDataVersion)) {
            String tlUrl = url + "/map-datacenter/rest/maps/jc_lrrl@datacenter";
            String sql = "data_version='"+tlDataVersion+"' and del_flag='0'";
            tlUrl = getSqlTempLayer(tlUrl, sql,true);//获取临时图层
            System.out.println("临时图层----"+tlUrl);
            //图例
            Layerr layerr = getLayerrByLayerNameUrl("jc_lrrl@datacenter", tlUrl);
            layerrs.add(layerr);
            Layer tlLayer = new Layer("TILE","jc_lrrl@datacenter", tlUrl);
            layers.add(tlLayer);
        }
        //城镇住宅
        String czzzNum = assessEmphasisVo.getCzzz().getNum();
        String czzzDataVersion = assessEmphasisVo.getCzzz().getDataVersion();
        String czzzDataset = "";
        if (PlatformObjectUtils.isNotEmpty(czzzDataVersion)) {
            if(czzzNum.equals("czzz")){
                czzzDataset = "jc_risk_census_city_house";
            }else{
                czzzDataset = "jc_risk_census_city_house_point";
            }
            String czzzUrl = url + "/map-datacenter/rest/maps/"+czzzDataset+"@datacenter";
            String sql = "data_version='"+czzzDataVersion+"' and del_flag='0'";
            czzzUrl = getSqlTempLayer(czzzUrl, sql,true);//获取临时图层
            System.out.println("临时图层----"+czzzUrl);
            //图例
            Layerr layerr = getLayerrByLayerNameUrl(czzzDataset+"@datacenter", czzzUrl);
            layerrs.add(layerr);
            Layer czzzLayer = new Layer("TILE",czzzDataset+"@datacenter", czzzUrl);
            layers.add(czzzLayer);
        }
        //城镇非住宅
        String czfzzNum = assessEmphasisVo.getCzfzz().getNum();
        String czfzzDataVersion = assessEmphasisVo.getCzfzz().getDataVersion();
        String czfzzDataset = "";
        if (PlatformObjectUtils.isNotEmpty(czfzzDataVersion)) {
            if(czfzzNum.equals("czfzz")){
                czfzzDataset = "jc_risk_census_city_non_house";
            }else{
                czfzzDataset = "jc_risk_census_city_non_house_point";
            }
            String czfzzUrl = url + "/map-datacenter/rest/maps/"+czfzzDataset+"@datacenter";
            String sql = "data_version='"+czfzzDataVersion+"' and del_flag='0'";
            czfzzUrl = getSqlTempLayer(czfzzUrl, sql,true);//获取临时图层
            System.out.println("临时图层----"+czfzzUrl);
            //图例
            Layerr layerr = getLayerrByLayerNameUrl(czfzzDataset+"@datacenter", czfzzUrl);
            layerrs.add(layerr);
            Layer czfzzLayer = new Layer("TILE",czfzzDataset+"@datacenter", czfzzUrl);
            layers.add(czfzzLayer);
        }
        //农村非住宅
        String ncfzzNum = assessEmphasisVo.getNcfzz().getNum();
        String ncfzzDataVersion = assessEmphasisVo.getNcfzz().getDataVersion();
        String ncfzzDataset = "";
        if (PlatformObjectUtils.isNotEmpty(ncfzzDataVersion)) {
            if(ncfzzNum.equals("ncfzz")){
                ncfzzDataset = "jc_risk_census_country_non_house";
            }else{
                ncfzzDataset = "jc_risk_census_country_non_house_point";
            }
            String ncfzzUrl = url + "/map-datacenter/rest/maps/"+ncfzzDataset+"@datacenter";
            String sql = "data_version='"+ncfzzDataVersion+"' and del_flag='0'";
            ncfzzUrl = getSqlTempLayer(ncfzzUrl, sql,true);//获取临时图层
            System.out.println("临时图层----"+ncfzzUrl);
            //图例
            Layerr layerr = getLayerrByLayerNameUrl(ncfzzDataset+"@datacenter", ncfzzUrl);
            layerrs.add(layerr);
            Layer ncfzzLayer = new Layer("TILE",ncfzzDataset+"@datacenter", ncfzzUrl);
            layers.add(ncfzzLayer);
        }
        //农村住宅(独立住宅)
        String nczzdlzzNum = assessEmphasisVo.getNczzdlzz().getNum();
        String nczzdlzzDataVersion = assessEmphasisVo.getNczzdlzz().getDataVersion();
        String nczzdlzzDataset = "";
        if (PlatformObjectUtils.isNotEmpty(nczzdlzzDataVersion)) {
            if(nczzdlzzNum.equals("nczzdlzz")){
                nczzdlzzDataset = "jc_risk_census_country_dl_house";
            }else{
                nczzdlzzDataset = "jc_risk_census_country_dl_house_point";
            }
            String nczzdlzzUrl = url + "/map-datacenter/rest/maps/"+nczzdlzzDataset+"@datacenter";
            String sql = "data_version='"+nczzdlzzDataVersion+"' and del_flag='0'";
            nczzdlzzUrl = getSqlTempLayer(nczzdlzzUrl, sql,true);//获取临时图层
            System.out.println("临时图层----"+nczzdlzzUrl);
            //图例
            Layerr layerr = getLayerrByLayerNameUrl(nczzdlzzDataset+"@datacenter", nczzdlzzUrl);
            layerrs.add(layerr);
            Layer nczzdlzzLayer = new Layer("TILE",nczzdlzzDataset+"@datacenter", nczzdlzzUrl);
            layers.add(nczzdlzzLayer);
        }
        //农村住宅(集合住宅)
        String nczzjhzzNum = assessEmphasisVo.getNczzjhzz().getNum();
        String nczzjhzzDataVersion = assessEmphasisVo.getNczzjhzz().getDataVersion();
        String nczzjhzzDataset = "";
        if (PlatformObjectUtils.isNotEmpty(nczzjhzzDataVersion)) {
            if(nczzjhzzNum.equals("nczzjhzz")){
                nczzjhzzDataset = "jc_risk_census_country_jh_house";
            }else{
                nczzjhzzDataset = "jc_risk_census_country_jh_house_point";
            }
            String nczzjhzzUrl = url + "/map-datacenter/rest/maps/"+nczzjhzzDataset+"@datacenter";
            String sql = "data_version='"+nczzjhzzDataVersion+"' and del_flag='0'";
            nczzjhzzUrl = getSqlTempLayer(nczzjhzzUrl, sql,true);//获取临时图层
            System.out.println("临时图层----"+nczzjhzzUrl);
            //图例
            Layerr layerr = getLayerrByLayerNameUrl(nczzjhzzDataset+"@datacenter", nczzjhzzUrl);
            layerrs.add(layerr);
            Layer nczzjhzzLayer = new Layer("TILE",nczzjhzzDataset+"@datacenter", nczzjhzzUrl);
            layers.add(nczzjhzzLayer);
        }
        //应急避难场所
        if(jcEmergcyShelterVos.size()>0){
            String yjbncsNum = assessEmphasisVo.getYjbncs().getNum();
            String yjbncsDataVersion = assessEmphasisVo.getYjbncs().getDataVersion();
            String yjbncsDataset = "";
            if(yjbncsNum.equals("csbncsm")){//应急避难场所面数据
                yjbncsDataset = "jc_emergcy_shelter_multipolygon";
            }else if(yjbncsNum.equals("csbncs")){//应急避难场所点数据
                yjbncsDataset = "jc_emergcy_shelter";
            }
            String yjbncsUrl = url + "/map-datacenter/rest/maps/"+yjbncsDataset+"@datacenter";
            String sql = "data_version='"+yjbncsDataVersion+"' and del_flag='0' and st_intersects(geom, st_geomfromtext('"+geom+"',4490))";
            yjbncsUrl = getSqlTempLayer(yjbncsUrl, sql,true);//获取临时图层
            System.out.println("临时图层----"+yjbncsUrl);
            //图例
            Layerr layerr = getLayerrByLayerNameUrl("应急避难场所", yjbncsUrl);
            layerrs.add(layerr);
            Layer yjbncsLayer = new Layer("TILE","应急避难场所", yjbncsUrl);
            layers.add(yjbncsLayer);
        }
        //路径规划结果临时图层路径
        String layerUrl = url + "/map-fxfzaqbz/rest/maps/sys_networkanalyst_path@fxfzaqbz";
        String ssId = site.getSsId();//重点目标ID
        String sqlText = "ss_id='"+ssId+"' and ctfw="+ctfw+
                " and version_id='"+networkId+"' and del_flag='0'";
        String tempLayerUrl = getSqlTempLayer(layerUrl, sqlText,true);//获取临时图层
        System.out.println("临时图层----"+tempLayerUrl);
        List<String> strings2 = new ArrayList<>();
        Layerr layerr2 = new Layerr(tempLayerUrl,strings2);
        layerrs.add(layerr2);
        Layer layer2 = new Layer("TILE","最佳路径规划", tempLayerUrl);
        layers.add(layer2);
        //重点目标
        String url1 = url + "/map-fxfzaqbz/rest/maps/sys_site@fxfzaqbz";
        String sql1 = "ss_id='"+ssId+"' and del_flag='0'";
        url1 = getSqlTempLayer(url1, sql1,true);//获取临时图层
        System.out.println("临时图层----"+url1);
        //图例
        Layerr layerr = getLayerrByLayerNameUrl("sys_site@fxfzaqbz", url1);
        layerrs.add(layerr);
        Layer layer1 = new Layer("TILE","重点场所", url1);
        layers.add(layer1);

        //获取Web打印出图模板列表
        List<TemplateEntity> templateEntityList = hypergraphService.getWebprintingLayoutsList();
        //根据参数设置请求体
        String jsonString = getRequestVOJsonStringByTjmb(assessEmphasisVo.getTjmb(),templateEntityList,tjbt,ztdw,layerrs,layers,centerX,centerY,leftX,leftY,rightX,rightY,level,true);
        Map map = JSONObject.parseObject(jsonString, Map.class);
        url = url + "/webprinting/rest/webprinting/v1/jobs.json?token=" + token;
        ResponseEntity<String> stringResponseEntity = restTemplateUtil.sendPostHttpRequest2(url, map);
        String resultBody = stringResponseEntity.getBody();
        List<ResponseVO> responseVO = JSON.parseArray(resultBody, ResponseVO.class);
        String path = "";
        String imageId = "";
        Map<String, Object> responseMap = new HashMap<>();
        if (responseVO != null || responseVO.size() > 0) {
            path = responseVO.get(0).getPath() + "/" + "result";
            //    String dateDir = new SimpleDateFormat("/yyyy/MM/dd").format(new Date());
            String savePath = localDir;
            path = path.replace("@", "%40");
            System.out.println("路径  " + path);
            String path2 = responseVO.get(0).getPath() + ".rjson";
            Map<String, Object> map2 = new HashMap<>();
            boolean flag = true;
            while (flag) {
                ResponseEntity<String> responseEntity = restTemplateUtil.sendHttpRequest3(path2, map2);
                String body1 = responseEntity.getBody();
                String[] split1 = body1.split("status");
                if (split1[1].contains("ERROR")) {
                    log.error("超图服务打印失败");
                    return RestResponse.fail("超图服务打印失败");
                }
                if (split1[1].contains("FINISHED")){
                    flag = false;
                    continue;
                }
                Thread.sleep(500);
            }
            restResponse = downloadsFile.downloadByUrl(path, savePath);
            imageId = restResponse.getData().toString();
            AttachmentInfoEntity attach = attachmentInfoService.getAttach(imageId);
            responseMap.put("attach", attach);
            responseMap.put("count", "地震应急疏散辅助决策图");
            responseMap.put("title", "");
            //删除基础地理数据超图工作空间服务
            if (PlatformObjectUtils.isNotEmpty(jsdlsjDataVersion)) {
                hypergraphService.deleteWorkspaceByVersion(jsdlsjDataVersion);
            }
        }
        File file = new File(localDir);
        File[] files = file.listFiles();
        for (File file1 : files) {
            if (file1.isFile()) {
                file1.delete();
            }
        }
        restResponse = RestResponse.succeed(responseMap);
        return restResponse;
    }

    //查询空间范围内显示数据图例列表
    public List<String> getLegendListByTableFieldGeom(String layerName,String tableName,String fieldName,String dataVersion,String geomText,String queryType){
        List<String> legendList = new ArrayList<>();
        //根据空间数据范围、表名、字段名称查询表按此字段分组的字段数据列表
        Properties configGroup = PropsHelper.loadProps("slw-config.properties");
        String url = configGroup.getProperty("restTemplateUrl") + "/districtQuery/getTableGroupDataByFieldGeom";
        if(queryType.equals("Integer")){
            url = configGroup.getProperty("restTemplateUrl") + "/districtQuery/getTableGroupDataByFieldGeomInt";
        }else if(queryType.equals("String")){
            url = configGroup.getProperty("restTemplateUrl") + "/districtQuery/getTableGroupDataByFieldGeom";
        }
        Map<String, Object> paramMap = new HashMap<>();
        paramMap.put("tableName", tableName);
        paramMap.put("fieldName", fieldName);
        paramMap.put("dataVersion", dataVersion);
        paramMap.put("geomText", geomText);
        ResponseEntity<String> responseEntity = restTemplateUtil.sendPostHttpRequest1(url, paramMap);
        if(queryType.equals("Integer")){
            List<Integer> resultList = JSONObject.parseArray(responseEntity.getBody(), Integer.class);
            if(resultList.size()>0){
                if(tableName.equals("jc_stratum_lithology") && layerName.equals("地震构造图地层年代")){//地层岩性
                    for(Integer value : resultList){
                        if(value==1){
                            legendList.add("jc_stratum_lithology@datacenter.1@@地震构造图地层年代");
                        }else if(value==2){
                            legendList.add("jc_stratum_lithology@datacenter.6@@地震构造图地层年代");
                        }else if(value==3){
                            legendList.add("jc_stratum_lithology@datacenter.5@@地震构造图地层年代");
                        }else if(value==4){
                            legendList.add("jc_stratum_lithology@datacenter.4@@地震构造图地层年代");
                        }else if(value==5){
                            legendList.add("jc_stratum_lithology@datacenter.3@@地震构造图地层年代");
                        }else if(value==6){
                            legendList.add("jc_stratum_lithology@datacenter.2@@地震构造图地层年代");
                        }else if(value==7){
                            legendList.add("jc_stratum_lithology@datacenter.12@@地震构造图地层年代");
                        }else if(value==8){
                            legendList.add("jc_stratum_lithology@datacenter.11@@地震构造图地层年代");
                        }else if(value==9){
                            legendList.add("jc_stratum_lithology@datacenter.10@@地震构造图地层年代");
                        }else if(value==10){
                            legendList.add("jc_stratum_lithology@datacenter.9@@地震构造图地层年代");
                        }else if(value==11){
                            legendList.add("jc_stratum_lithology@datacenter.8@@地震构造图地层年代");
                        }else if(value==12){
                            legendList.add("jc_stratum_lithology@datacenter.7@@地震构造图地层年代");
                        }else if(value==13){
                            legendList.add("jc_stratum_lithology@datacenter.16@@地震构造图地层年代");
                        }else if(value==14){
                            legendList.add("jc_stratum_lithology@datacenter.15@@地震构造图地层年代");
                        }else if(value==15){
                            legendList.add("jc_stratum_lithology@datacenter.14@@地震构造图地层年代");
                        }else if(value==16){
                            legendList.add("jc_stratum_lithology@datacenter.13@@地震构造图地层年代");
                        }else if(value==17){
                            legendList.add("jc_stratum_lithology@datacenter@@地震构造图地层年代");
                        }else if(value>=18 && value<=20){
                            legendList.add("jc_stratum_lithology@datacenter.17@@地震构造图地层年代");
                        }else if(value>=21 && value<=25){
                            legendList.add("jc_stratum_lithology@datacenter.20@@地震构造图地层年代");
                        }else if(value==26){
                            legendList.add("jc_stratum_lithology@datacenter.19@@地震构造图地层年代");
                        }else if(value>=27 && value<=29){
                            legendList.add("jc_stratum_lithology@datacenter.22@@地震构造图地层年代");
                        }else if(value>=30 && value<=34){
                            legendList.add("jc_stratum_lithology@datacenter.21@@地震构造图地层年代");
                        }else if(value>=35 && value<=37){
                            legendList.add("jc_stratum_lithology@datacenter.18@@地震构造图地层年代");
                        }else if(value==38){
                            legendList.add("jc_stratum_lithology@datacenter.27@@地震构造图地层年代");
                        }else if(value==39){
                            legendList.add("jc_stratum_lithology@datacenter.26@@地震构造图地层年代");
                        }else if(value==40){
                            legendList.add("jc_stratum_lithology@datacenter.25@@地震构造图地层年代");
                        }else if(value>=41 && value<=55){
                            legendList.add("jc_stratum_lithology@datacenter.24@@地震构造图地层年代");
                        }else if(value>=56 && value<=66){
                            legendList.add("jc_stratum_lithology@datacenter.23@@地震构造图地层年代");
                        }else if(value>=67 && value<=77){
                            legendList.add("jc_stratum_lithology@datacenter.28@@地震构造图地层年代");
                        }else if(value>=78 && value<=79){
                            legendList.add("jc_stratum_lithology@datacenter.30@@地震构造图地层年代");
                        }else if(value>=80 && value<=91){
                            legendList.add("jc_stratum_lithology@datacenter.29@@地震构造图地层年代");
                        }else if(value>=92 && value<=101){
                            legendList.add("jc_stratum_lithology@datacenter.31@@地震构造图地层年代");
                        }else if(value>=102 && value<=113){
                            legendList.add("jc_stratum_lithology@datacenter.51@@地震构造图地层年代");
                        }else if(value>=114 && value<=122){
                            legendList.add("jc_stratum_lithology@datacenter.50@@地震构造图地层年代");
                        }else if(value>=123 && value<=132){
                            legendList.add("jc_stratum_lithology@datacenter.49@@地震构造图地层年代");
                        }else if(value>=133 && value<=146){
                            legendList.add("jc_stratum_lithology@datacenter.48@@地震构造图地层年代");
                        }else if(value==147){
                            legendList.add("jc_stratum_lithology@datacenter.47@@地震构造图地层年代");
                        }else if(value==148){
                            legendList.add("jc_stratum_lithology@datacenter.46@@地震构造图地层年代");
                        }else if(value==149){
                            legendList.add("jc_stratum_lithology@datacenter.45@@地震构造图地层年代");
                        }else if(value>=150 && value<=154){
                            legendList.add("jc_stratum_lithology@datacenter.44@@地震构造图地层年代");
                        }else if(value>=155 && value<=157){
                            legendList.add("jc_stratum_lithology@datacenter.43@@地震构造图地层年代");
                        }else if(value>=158 && value<=160){
                            legendList.add("jc_stratum_lithology@datacenter.42@@地震构造图地层年代");
                        }else if(value==161){
                            legendList.add("jc_stratum_lithology@datacenter.41@地震构造图地层年代");
                        }else if(value>=162 && value<=164){
                            legendList.add("jc_stratum_lithology@datacenter.40@@地震构造图地层年代");
                        }else if(value>=165 && value<=167){
                            legendList.add("jc_stratum_lithology@datacenter.39@@地震构造图地层年代");
                        }else if(value==168){
                            legendList.add("jc_stratum_lithology@datacenter.38@@地震构造图地层年代");
                        }else if(value==169){
                            legendList.add("jc_stratum_lithology@datacenter.37@@地震构造图地层年代");
                        }else if(value==170){
                            legendList.add("jc_stratum_lithology@datacenter.36@@地震构造图地层年代");
                        }else if(value==171){
                            legendList.add("jc_stratum_lithology@datacenter.35@@地震构造图地层年代");
                        }else if(value==172){
                            legendList.add("jc_stratum_lithology@datacenter.34@@地震构造图地层年代");
                        }else if(value==173){
                            legendList.add("jc_stratum_lithology@datacenter.33@@地震构造图地层年代");
                        }else if(value==174){
                            legendList.add("jc_stratum_lithology@datacenter.32@@地震构造图地层年代");
                        }else if(value>=175 && value<=176){
                            legendList.add("jc_stratum_lithology@datacenter.52@@地震构造图地层年代");
                        }
                    }
                }
            }
        }

        return legendList;
    }
}
